From b5f7ed7cc89ec40a79cc1e0e8fdbe738152822fe Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Mon, 29 Mar 2021 21:03:15 +0200 Subject: [PATCH 1/4] ocamlPackages.shared-memory-ring(-lwt): init at 3.1.0 --- .../shared-memory-ring/default.nix | 41 +++++++++++++++++++ .../ocaml-modules/shared-memory-ring/lwt.nix | 37 +++++++++++++++++ pkgs/top-level/ocaml-packages.nix | 4 ++ 3 files changed, 82 insertions(+) create mode 100644 pkgs/development/ocaml-modules/shared-memory-ring/default.nix create mode 100644 pkgs/development/ocaml-modules/shared-memory-ring/lwt.nix diff --git a/pkgs/development/ocaml-modules/shared-memory-ring/default.nix b/pkgs/development/ocaml-modules/shared-memory-ring/default.nix new file mode 100644 index 00000000000..3a96d4adee4 --- /dev/null +++ b/pkgs/development/ocaml-modules/shared-memory-ring/default.nix @@ -0,0 +1,41 @@ +{ lib +, buildDunePackage +, fetchurl +, ppx_cstruct +, mirage-profile +, cstruct +, ounit +}: + +buildDunePackage rec { + pname = "shared-memory-ring"; + version = "3.1.0"; + + useDune2 = true; + + src = fetchurl { + url = "https://github.com/mirage/shared-memory-ring/releases/download/v${version}/shared-memory-ring-v${version}.tbz"; + sha256 = "06350ph3rdfvybi0cgs3h3rdkmjspk3c4375rxvbdg0kza1w22x1"; + }; + + nativeBuildInputs = [ + ppx_cstruct + ]; + + propagatedBuildInputs = [ + mirage-profile + cstruct + ]; + + doCheck = true; + checkInputs = [ + ounit + ]; + + meta = with lib; { + description = "Shared memory rings for RPC and bytestream communications"; + license = licenses.isc; + homepage = "https://github.com/mirage/shared-memory-ring"; + maintainers = [ maintainers.sternenseemann ]; + }; +} diff --git a/pkgs/development/ocaml-modules/shared-memory-ring/lwt.nix b/pkgs/development/ocaml-modules/shared-memory-ring/lwt.nix new file mode 100644 index 00000000000..8f41253bab8 --- /dev/null +++ b/pkgs/development/ocaml-modules/shared-memory-ring/lwt.nix @@ -0,0 +1,37 @@ +{ lib +, buildDunePackage +, shared-memory-ring +, ppx_cstruct +, cstruct +, lwt +, lwt-dllist +, mirage-profile +, ounit +}: + +buildDunePackage { + pname = "shared-memory-ring-lwt"; + + inherit (shared-memory-ring) version src useDune2; + + buildInputs = [ + ppx_cstruct + ]; + + propagatedBuildInputs = [ + shared-memory-ring + cstruct + lwt + lwt-dllist + mirage-profile + ]; + + doCheck = true; + checkInputs = [ + ounit + ]; + + meta = shared-memory-ring.meta // { + description = "Shared memory rings for RPC and bytestream communications using Lwt"; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index d8c1f2d3e40..5e33c619ca0 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -1138,6 +1138,10 @@ let sha = callPackage ../development/ocaml-modules/sha { }; + shared-memory-ring = callPackage ../development/ocaml-modules/shared-memory-ring { }; + + shared-memory-ring-lwt = callPackage ../development/ocaml-modules/shared-memory-ring/lwt.nix { }; + sodium = callPackage ../development/ocaml-modules/sodium { }; spelll = callPackage ../development/ocaml-modules/spelll { }; From 980a2bed3bdb2801d7aee238decdf62c014b56f4 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Mon, 29 Mar 2021 21:03:38 +0200 Subject: [PATCH 2/4] ocamlPackages.mirage-xen: init at 6.0.0 Unfortunately this requires a bit of trickery with pkg-config to get to work. The root issue is that the mirage-xen assumes that we use the default libdir of dune ($out/lib) whereas we install to an OCaml version-specific site-lib directory. Thus the manually created pkg-config file makes wrong assumptions (which warrants a patch) and the .pc file is installed to the wrong location (which is fixed with a mv invocation). --- .../ocaml-modules/mirage-xen/default.nix | 78 +++++++++++++++++++ .../mirage-xen/makefile-no-opam.patch | 12 +++ .../ocaml-modules/mirage-xen/pkg-config.patch | 13 ++++ pkgs/top-level/ocaml-packages.nix | 2 + 4 files changed, 105 insertions(+) create mode 100644 pkgs/development/ocaml-modules/mirage-xen/default.nix create mode 100644 pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch create mode 100644 pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch diff --git a/pkgs/development/ocaml-modules/mirage-xen/default.nix b/pkgs/development/ocaml-modules/mirage-xen/default.nix new file mode 100644 index 00000000000..0d53d0f9c3b --- /dev/null +++ b/pkgs/development/ocaml-modules/mirage-xen/default.nix @@ -0,0 +1,78 @@ +{ lib +, buildDunePackage +, fetchurl +, pkg-config +, cstruct +, lwt +, shared-memory-ring-lwt +, xenstore +, lwt-dllist +, mirage-profile +, mirage-runtime +, logs +, fmt +, ocaml-freestanding +, bheap +, duration +, io-page +}: + +buildDunePackage rec { + pname = "mirage-xen"; + version = "6.0.0"; + + useDune2 = true; + + src = fetchurl { + url = "https://github.com/mirage/mirage-xen/releases/download/v${version}/mirage-xen-v${version}.tbz"; + sha256 = "f991e972059b27993c287ad010d9281fee061efaa1dd475d0955179f93710fbd"; + }; + + patches = [ + ./makefile-no-opam.patch + ./pkg-config.patch + ]; + + # can't handle OCAMLFIND_DESTDIR with substituteAll + postPatch = '' + substituteInPlace lib/bindings/mirage-xen.pc \ + --replace "@out@" "$out" \ + --replace "@OCAMLFIND_DESTDIR@" "$OCAMLFIND_DESTDIR" + ''; + + minimumOCamlVersion = "4.08"; + + nativeBuildInputs = [ + pkg-config + ]; + + propagatedBuildInputs = [ + cstruct + lwt + shared-memory-ring-lwt + xenstore + lwt-dllist + mirage-profile + mirage-runtime + io-page + logs + fmt + bheap + duration + (ocaml-freestanding.override { target = "xen"; }) + ]; + + # Move pkg-config files into their well-known location. + # This saves us an extra setup hook and causes no issues + # since we patch all relative paths out of the .pc file. + postInstall = '' + mv $OCAMLFIND_DESTDIR/pkgconfig $out/lib/pkgconfig + ''; + + meta = with lib; { + description = "Xen core platform libraries for MirageOS"; + license = licenses.isc; + maintainers = [ maintainers.sternenseemann ]; + homepage = "https://github.com/mirage/mirage-xen"; + }; +} diff --git a/pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch b/pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch new file mode 100644 index 00000000000..905e6efc3f4 --- /dev/null +++ b/pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch @@ -0,0 +1,12 @@ +diff --git a/lib/bindings/Makefile b/lib/bindings/Makefile +index 4e413c0..67c7bdc 100644 +--- a/lib/bindings/Makefile ++++ b/lib/bindings/Makefile +@@ -1,4 +1,6 @@ +-PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig ++ifneq (, $(shell command -v opam)) ++ PKG_CONFIG_PATH ?= $(shell opam config var prefix)/lib/pkgconfig ++endif + + CC ?= cc + FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags ocaml-freestanding) diff --git a/pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch b/pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch new file mode 100644 index 00000000000..19205cf7ee4 --- /dev/null +++ b/pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch @@ -0,0 +1,13 @@ +diff --git a/lib/bindings/mirage-xen.pc b/lib/bindings/mirage-xen.pc +index a03a217..8499aa4 100644 +--- a/lib/bindings/mirage-xen.pc ++++ b/lib/bindings/mirage-xen.pc +@@ -1,6 +1,6 @@ +-prefix=${pcfiledir}/../.. ++prefix=@out@ + exec_prefix=${prefix} +-libdir=${exec_prefix}/lib ++libdir=@OCAMLFIND_DESTDIR@ + + Name: mirage-xen + Version: 6.0.0 diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 5e33c619ca0..66df06b2058 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -739,6 +739,8 @@ let mirage-unix = callPackage ../development/ocaml-modules/mirage-unix { }; + mirage-xen = callPackage ../development/ocaml-modules/mirage-xen { }; + mirage-vnetif = callPackage ../development/ocaml-modules/mirage-vnetif { }; mlgmp = callPackage ../development/ocaml-modules/mlgmp { }; From 2fe8239172c3aeccfd14910638aa74e440516b2a Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 20 Apr 2021 13:41:47 +0200 Subject: [PATCH 3/4] ocamlPackages.{mirage-net-xen,netchannel}: init at 2.0.0 --- .../ocaml-modules/mirage-net-xen/default.nix | 39 +++++++++++++ .../ocaml-modules/netchannel/default.nix | 55 +++++++++++++++++++ pkgs/top-level/ocaml-packages.nix | 4 ++ 3 files changed, 98 insertions(+) create mode 100644 pkgs/development/ocaml-modules/mirage-net-xen/default.nix create mode 100644 pkgs/development/ocaml-modules/netchannel/default.nix diff --git a/pkgs/development/ocaml-modules/mirage-net-xen/default.nix b/pkgs/development/ocaml-modules/mirage-net-xen/default.nix new file mode 100644 index 00000000000..0d7a7e53fb1 --- /dev/null +++ b/pkgs/development/ocaml-modules/mirage-net-xen/default.nix @@ -0,0 +1,39 @@ +{ lib +, buildDunePackage +, netchannel +, ppx_sexp_conv +, lwt +, cstruct +, mirage-net +, mirage-xen +, io-page +, lwt-dllist +, logs +}: + +buildDunePackage { + pname = "mirage-net-xen"; + + inherit (netchannel) + src + version + useDune2 + minimumOCamlVersion + meta + ; + + nativeBuildInputs = [ + ppx_sexp_conv + ]; + + propagatedBuildInputs = [ + lwt + cstruct + netchannel + mirage-net + mirage-xen + io-page + lwt-dllist + logs + ]; +} diff --git a/pkgs/development/ocaml-modules/netchannel/default.nix b/pkgs/development/ocaml-modules/netchannel/default.nix new file mode 100644 index 00000000000..e7b021d6fbe --- /dev/null +++ b/pkgs/development/ocaml-modules/netchannel/default.nix @@ -0,0 +1,55 @@ +{ lib +, buildDunePackage +, fetchurl +, ppx_sexp_conv +, ppx_cstruct +, lwt +, mirage-net +, io-page +, mirage-xen +, ipaddr +, mirage-profile +, shared-memory-ring +, sexplib +, logs +, rresult +}: + +buildDunePackage rec { + pname = "netchannel"; + version = "2.0.0"; + + useDune2 = true; + + minimumOCamlVersion = "4.08"; + + src = fetchurl { + url = "https://github.com/mirage/mirage-net-xen/releases/download/v${version}/mirage-net-xen-v${version}.tbz"; + sha256 = "ec3906ef1804ef6a9e36b91f4ae73ce4849e9e0d1d36a80fe66b5f905fab93ad"; + }; + + nativeBuildInputs = [ + ppx_cstruct + ]; + + propagatedBuildInputs = [ + ppx_sexp_conv + lwt + mirage-net + io-page + mirage-xen + ipaddr + mirage-profile + shared-memory-ring + sexplib + logs + rresult + ]; + + meta = with lib; { + description = "Network device for reading and writing Ethernet frames via then Xen netfront/netback protocol"; + license = licenses.isc; + maintainers = [ maintainers.sternenseemann ]; + homepage = "https://github.com/mirage/mirage-net-xen"; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 66df06b2058..6bbcb9fbc8c 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -717,6 +717,8 @@ let mirage-net = callPackage ../development/ocaml-modules/mirage-net { }; + mirage-net-xen = callPackage ../development/ocaml-modules/mirage-net-xen { }; + mirage-profile = callPackage ../development/ocaml-modules/mirage-profile { }; mirage-protocols = callPackage ../development/ocaml-modules/mirage-protocols { }; @@ -755,6 +757,8 @@ let mustache = callPackage ../development/ocaml-modules/mustache { }; + netchannel = callPackage ../development/ocaml-modules/netchannel { }; + nocrypto = callPackage ../development/ocaml-modules/nocrypto { }; nonstd = callPackage ../development/ocaml-modules/nonstd { }; From 4f7a6610f700bdd1e9dab7b5b3efa125465ae797 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 30 Mar 2021 02:40:43 +0200 Subject: [PATCH 4/4] ocamlPackages.mirage-bootvar-xen: init at 0.8.0 --- .../mirage-bootvar-xen/default.nix | 34 +++++++++++++++++++ pkgs/top-level/ocaml-packages.nix | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 pkgs/development/ocaml-modules/mirage-bootvar-xen/default.nix diff --git a/pkgs/development/ocaml-modules/mirage-bootvar-xen/default.nix b/pkgs/development/ocaml-modules/mirage-bootvar-xen/default.nix new file mode 100644 index 00000000000..c280853488d --- /dev/null +++ b/pkgs/development/ocaml-modules/mirage-bootvar-xen/default.nix @@ -0,0 +1,34 @@ +{ lib +, buildDunePackage +, fetchurl +, mirage-xen +, parse-argv +, lwt +}: + +buildDunePackage rec { + pname = "mirage-bootvar-xen"; + version = "0.8.0"; + + minimumOCamlVersion = "4.08"; + + useDune2 = true; + + src = fetchurl { + url = "https://github.com/mirage/mirage-bootvar-xen/releases/download/v${version}/mirage-bootvar-xen-v${version}.tbz"; + sha256 = "0nk80giq9ng3svbnm68fjby2f1dnarddm3lk7mw7w59av71q0rcv"; + }; + + propagatedBuildInputs = [ + mirage-xen + lwt + parse-argv + ]; + + meta = with lib; { + description = "Handle boot-time arguments for Xen platform"; + license = licenses.isc; + maintainers = [ maintainers.sternenseemann ]; + homepage = "https://github.com/mirage/mirage-bootvar-xen"; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 6bbcb9fbc8c..c7891a1821e 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -675,6 +675,8 @@ let mirage-bootvar-unix = callPackage ../development/ocaml-modules/mirage-bootvar-unix { }; + mirage-bootvar-xen = callPackage ../development/ocaml-modules/mirage-bootvar-xen { }; + mirage-channel = callPackage ../development/ocaml-modules/mirage-channel { }; mirage-clock = callPackage ../development/ocaml-modules/mirage-clock { };