Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

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).

+105
+78
pkgs/development/ocaml-modules/mirage-xen/default.nix
··· 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 + }
+12
pkgs/development/ocaml-modules/mirage-xen/makefile-no-opam.patch
··· 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)
+13
pkgs/development/ocaml-modules/mirage-xen/pkg-config.patch
··· 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
+2
pkgs/top-level/ocaml-packages.nix
··· 739 739 740 740 mirage-unix = callPackage ../development/ocaml-modules/mirage-unix { }; 741 741 742 + mirage-xen = callPackage ../development/ocaml-modules/mirage-xen { }; 743 + 742 744 mirage-vnetif = callPackage ../development/ocaml-modules/mirage-vnetif { }; 743 745 744 746 mlgmp = callPackage ../development/ocaml-modules/mlgmp { };