git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #118066 from sternenseemann/mirage-xen

ocamlPackages: init a bunch of libraries for the MirageOS xen target

commita86418ac62a03001c741339a9d045752762b0d68 authorJohn Ericson <git@JohnEricson.me> dateSun 25 Apr 2021, 10:13 (6 years ago) parent14b427a4f7a661
9 files changed+321
pkgs/development/ocaml-modules/mirage-bootvar-xen/default.nix+34 pkgs/development/ocaml-modules/mirage-net-xen/default.nix+39 pkgs/development/ocaml-modules/mirage-xen/default.nix+78 pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch+12 pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch+13 pkgs/development/ocaml-modules/netchannel/default.nix+55 pkgs/development/ocaml-modules/shared-memory-ring/default.nix+41 pkgs/development/ocaml-modules/shared-memory-ring/lwt.nix+37 pkgs/top-level/ocaml-packages.nix+12
pkgs/development/ocaml-modules/mirage-bootvar-xen/default.nixnew file+34
@@ -0,0 +1,34 @@
1+{ lib
2+, buildDunePackage
3+, fetchurl
4+, mirage-xen
5+, parse-argv
6+, lwt
7+}:
8+
9+buildDunePackage rec {
10+ pname = "mirage-bootvar-xen";
11+ version = "0.8.0";
12+
13+ minimumOCamlVersion = "4.08";
14+
15+ useDune2 = true;
16+
17+ src = fetchurl {
18+ url = "https://github.com/mirage/mirage-bootvar-xen/releases/download/v${version}/mirage-bootvar-xen-v${version}.tbz";
19+ sha256 = "0nk80giq9ng3svbnm68fjby2f1dnarddm3lk7mw7w59av71q0rcv";
20+ };
21+
22+ propagatedBuildInputs = [
23+ mirage-xen
24+ lwt
25+ parse-argv
26+ ];
27+
28+ meta = with lib; {
29+ description = "Handle boot-time arguments for Xen platform";
30+ license = licenses.isc;
31+ maintainers = [ maintainers.sternenseemann ];
32+ homepage = "https://github.com/mirage/mirage-bootvar-xen";
33+ };
34+}
pkgs/development/ocaml-modules/mirage-net-xen/default.nixnew file+39
@@ -0,0 +1,39 @@
1+{ lib
2+, buildDunePackage
3+, netchannel
4+, ppx_sexp_conv
5+, lwt
6+, cstruct
7+, mirage-net
8+, mirage-xen
9+, io-page
10+, lwt-dllist
11+, logs
12+}:
13+
14+buildDunePackage {
15+ pname = "mirage-net-xen";
16+
17+ inherit (netchannel)
18+ src
19+ version
20+ useDune2
21+ minimumOCamlVersion
22+ meta
23+ ;
24+
25+ nativeBuildInputs = [
26+ ppx_sexp_conv
27+ ];
28+
29+ propagatedBuildInputs = [
30+ lwt
31+ cstruct
32+ netchannel
33+ mirage-net
34+ mirage-xen
35+ io-page
36+ lwt-dllist
37+ logs
38+ ];
39+}
pkgs/development/ocaml-modules/mirage-xen/default.nixnew file+78
@@ -0,0 +1,78 @@
1+{ lib
2+, buildDunePackage
3+, fetchurl
4+, pkg-config
5+, cstruct
6+, lwt
7+, shared-memory-ring-lwt
8+, xenstore
9+, lwt-dllist
10+, mirage-profile
11+, mirage-runtime
12+, logs
13+, fmt
14+, ocaml-freestanding
15+, bheap
16+, duration
17+, io-page
18+}:
19+
20+buildDunePackage rec {
21+ pname = "mirage-xen";
22+ version = "6.0.0";
23+
24+ useDune2 = true;
25+
26+ src = fetchurl {
27+ url = "https://github.com/mirage/mirage-xen/releases/download/v${version}/mirage-xen-v${version}.tbz";
28+ sha256 = "f991e972059b27993c287ad010d9281fee061efaa1dd475d0955179f93710fbd";
29+ };
30+
31+ patches = [
32+ ./makefile-no-opam.patch
33+ ./pkg-config.patch
34+ ];
35+
36+ # can't handle OCAMLFIND_DESTDIR with substituteAll
37+ postPatch = ''
38+ substituteInPlace lib/bindings/mirage-xen.pc \
39+ --replace "@out@" "$out" \
40+ --replace "@OCAMLFIND_DESTDIR@" "$OCAMLFIND_DESTDIR"
41+ '';
42+
43+ minimumOCamlVersion = "4.08";
44+
45+ nativeBuildInputs = [
46+ pkg-config
47+ ];
48+
49+ propagatedBuildInputs = [
50+ cstruct
51+ lwt
52+ shared-memory-ring-lwt
53+ xenstore
54+ lwt-dllist
55+ mirage-profile
56+ mirage-runtime
57+ io-page
58+ logs
59+ fmt
60+ bheap
61+ duration
62+ (ocaml-freestanding.override { target = "xen"; })
63+ ];
64+
65+ # Move pkg-config files into their well-known location.
66+ # This saves us an extra setup hook and causes no issues
67+ # since we patch all relative paths out of the .pc file.
68+ postInstall = ''
69+ mv $OCAMLFIND_DESTDIR/pkgconfig $out/lib/pkgconfig
70+ '';
71+
72+ meta = with lib; {
73+ description = "Xen core platform libraries for MirageOS";
74+ license = licenses.isc;
75+ maintainers = [ maintainers.sternenseemann ];
76+ homepage = "https://github.com/mirage/mirage-xen";
77+ };
78+}
pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patchnew file+12
@@ -0,0 +1,12 @@
1+diff --git a/lib/bindings/Makefile b/lib/bindings/Makefile
2+index 4e413c0..67c7bdc 100644
3+--- a/lib/bindings/Makefile
4++++ b/lib/bindings/Makefile
5+@@ -1,4 +1,6 @@
6+-PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig
7++ifneq (, $(shell command -v opam))
8++ PKG_CONFIG_PATH ?= $(shell opam config var prefix)/lib/pkgconfig
9++endif
10+
11+ CC ?= cc
12+ FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags ocaml-freestanding)
pkgs/development/ocaml-modules/mirage-xen/pkg-config.patchnew file+13
@@ -0,0 +1,13 @@
1+diff --git a/lib/bindings/mirage-xen.pc b/lib/bindings/mirage-xen.pc
2+index a03a217..8499aa4 100644
3+--- a/lib/bindings/mirage-xen.pc
4++++ b/lib/bindings/mirage-xen.pc
5+@@ -1,6 +1,6 @@
6+-prefix=${pcfiledir}/../..
7++prefix=@out@
8+ exec_prefix=${prefix}
9+-libdir=${exec_prefix}/lib
10++libdir=@OCAMLFIND_DESTDIR@
11+
12+ Name: mirage-xen
13+ Version: 6.0.0
pkgs/development/ocaml-modules/netchannel/default.nixnew file+55
@@ -0,0 +1,55 @@
1+{ lib
2+, buildDunePackage
3+, fetchurl
4+, ppx_sexp_conv
5+, ppx_cstruct
6+, lwt
7+, mirage-net
8+, io-page
9+, mirage-xen
10+, ipaddr
11+, mirage-profile
12+, shared-memory-ring
13+, sexplib
14+, logs
15+, rresult
16+}:
17+
18+buildDunePackage rec {
19+ pname = "netchannel";
20+ version = "2.0.0";
21+
22+ useDune2 = true;
23+
24+ minimumOCamlVersion = "4.08";
25+
26+ src = fetchurl {
27+ url = "https://github.com/mirage/mirage-net-xen/releases/download/v${version}/mirage-net-xen-v${version}.tbz";
28+ sha256 = "ec3906ef1804ef6a9e36b91f4ae73ce4849e9e0d1d36a80fe66b5f905fab93ad";
29+ };
30+
31+ nativeBuildInputs = [
32+ ppx_cstruct
33+ ];
34+
35+ propagatedBuildInputs = [
36+ ppx_sexp_conv
37+ lwt
38+ mirage-net
39+ io-page
40+ mirage-xen
41+ ipaddr
42+ mirage-profile
43+ shared-memory-ring
44+ sexplib
45+ logs
46+ rresult
47+ ];
48+
49+ meta = with lib; {
50+ description = "Network device for reading and writing Ethernet frames via then Xen netfront/netback protocol";
51+ license = licenses.isc;
52+ maintainers = [ maintainers.sternenseemann ];
53+ homepage = "https://github.com/mirage/mirage-net-xen";
54+ };
55+}
pkgs/development/ocaml-modules/shared-memory-ring/default.nixnew file+41
@@ -0,0 +1,41 @@
1+{ lib
2+, buildDunePackage
3+, fetchurl
4+, ppx_cstruct
5+, mirage-profile
6+, cstruct
7+, ounit
8+}:
9+
10+buildDunePackage rec {
11+ pname = "shared-memory-ring";
12+ version = "3.1.0";
13+
14+ useDune2 = true;
15+
16+ src = fetchurl {
17+ url = "https://github.com/mirage/shared-memory-ring/releases/download/v${version}/shared-memory-ring-v${version}.tbz";
18+ sha256 = "06350ph3rdfvybi0cgs3h3rdkmjspk3c4375rxvbdg0kza1w22x1";
19+ };
20+
21+ nativeBuildInputs = [
22+ ppx_cstruct
23+ ];
24+
25+ propagatedBuildInputs = [
26+ mirage-profile
27+ cstruct
28+ ];
29+
30+ doCheck = true;
31+ checkInputs = [
32+ ounit
33+ ];
34+
35+ meta = with lib; {
36+ description = "Shared memory rings for RPC and bytestream communications";
37+ license = licenses.isc;
38+ homepage = "https://github.com/mirage/shared-memory-ring";
39+ maintainers = [ maintainers.sternenseemann ];
40+ };
41+}
pkgs/development/ocaml-modules/shared-memory-ring/lwt.nixnew file+37
@@ -0,0 +1,37 @@
1+{ lib
2+, buildDunePackage
3+, shared-memory-ring
4+, ppx_cstruct
5+, cstruct
6+, lwt
7+, lwt-dllist
8+, mirage-profile
9+, ounit
10+}:
11+
12+buildDunePackage {
13+ pname = "shared-memory-ring-lwt";
14+
15+ inherit (shared-memory-ring) version src useDune2;
16+
17+ buildInputs = [
18+ ppx_cstruct
19+ ];
20+
21+ propagatedBuildInputs = [
22+ shared-memory-ring
23+ cstruct
24+ lwt
25+ lwt-dllist
26+ mirage-profile
27+ ];
28+
29+ doCheck = true;
30+ checkInputs = [
31+ ounit
32+ ];
33+
34+ meta = shared-memory-ring.meta // {
35+ description = "Shared memory rings for RPC and bytestream communications using Lwt";
36+ };
37+}
pkgs/top-level/ocaml-packages.nix+12
@@ -675,6 +675,8 @@ let
675675
676676 mirage-bootvar-unix = callPackage ../development/ocaml-modules/mirage-bootvar-unix { };
677677
678+ mirage-bootvar-xen = callPackage ../development/ocaml-modules/mirage-bootvar-xen { };
679+
678680 mirage-channel = callPackage ../development/ocaml-modules/mirage-channel { };
679681
680682 mirage-clock = callPackage ../development/ocaml-modules/mirage-clock { };
@@ -717,6 +719,8 @@ let
717719
718720 mirage-net = callPackage ../development/ocaml-modules/mirage-net { };
719721
722+ mirage-net-xen = callPackage ../development/ocaml-modules/mirage-net-xen { };
723+
720724 mirage-profile = callPackage ../development/ocaml-modules/mirage-profile { };
721725
722726 mirage-protocols = callPackage ../development/ocaml-modules/mirage-protocols { };
@@ -739,6 +743,8 @@ let
739743
740744 mirage-unix = callPackage ../development/ocaml-modules/mirage-unix { };
741745
746+ mirage-xen = callPackage ../development/ocaml-modules/mirage-xen { };
747+
742748 mirage-vnetif = callPackage ../development/ocaml-modules/mirage-vnetif { };
743749
744750 mlgmp = callPackage ../development/ocaml-modules/mlgmp { };
@@ -753,6 +759,8 @@ let
753759
754760 mustache = callPackage ../development/ocaml-modules/mustache { };
755761
762+ netchannel = callPackage ../development/ocaml-modules/netchannel { };
763+
756764 nocrypto = callPackage ../development/ocaml-modules/nocrypto { };
757765
758766 nonstd = callPackage ../development/ocaml-modules/nonstd { };
@@ -1138,6 +1146,10 @@ let
11381146
11391147 sha = callPackage ../development/ocaml-modules/sha { };
11401148
1149+ shared-memory-ring = callPackage ../development/ocaml-modules/shared-memory-ring { };
1150+
1151+ shared-memory-ring-lwt = callPackage ../development/ocaml-modules/shared-memory-ring/lwt.nix { };
1152+
11411153 sodium = callPackage ../development/ocaml-modules/sodium { };
11421154
11431155 spelll = callPackage ../development/ocaml-modules/spelll { };