summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/mirage-xen
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-03-29 21:03:38 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-04-25 13:13:23 +0200
commit980a2bed3bdb2801d7aee238decdf62c014b56f4 (patch)
tree787410730c2233d3ab94307f35fabe128390db0b /pkgs/development/ocaml-modules/mirage-xen
parentb5f7ed7cc89ec40a79cc1e0e8fdbe738152822fe (diff)
downloadnixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.tar
nixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.tar.gz
nixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.tar.bz2
nixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.tar.lz
nixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.tar.xz
nixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.tar.zst
nixpkgs-980a2bed3bdb2801d7aee238decdf62c014b56f4.zip
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).
Diffstat (limited to 'pkgs/development/ocaml-modules/mirage-xen')
-rw-r--r--pkgs/development/ocaml-modules/mirage-xen/default.nix78
-rw-r--r--pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch12
-rw-r--r--pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch13
3 files changed, 103 insertions, 0 deletions
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