Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / so / solo5 / package.nix
blob1ca866c81e5e2c02d4468149826d21d149ff6e1e
1 { lib, stdenv, fetchurl, dosfstools, libseccomp, makeWrapper, mtools, parted
2 , pkg-config, qemu_test, syslinux, util-linux }:
4 let
5   version = "0.8.1";
6   # list of all theoretically available targets
7   targets = [
8     "genode"
9     "hvt"
10     "muen"
11     "spt"
12     "virtio"
13     "xen"
14   ];
15 in stdenv.mkDerivation {
16   pname = "solo5";
17   inherit version;
19   nativeBuildInputs = [ makeWrapper pkg-config ];
20   buildInputs = lib.optional (stdenv.hostPlatform.isLinux) libseccomp;
22   src = fetchurl {
23     url = "https://github.com/Solo5/solo5/releases/download/v${version}/solo5-v${version}.tar.gz";
24     sha256 = "sha256-J1xcL/AdcLQ7Ph3TFwEaS9l4cWjDQsTaXTdBDcT7p6E=";
25   };
27   hardeningEnable = [ "pie" ];
29   configurePhase = ''
30     runHook preConfigure
31     sh configure.sh --prefix=/
32     runHook postConfigure
33   '';
35   enableParallelBuilding = true;
37   separateDebugInfo = true;
38     # debugging requires information for both the unikernel and the tender
40   installPhase = ''
41     runHook preInstall
42     export DESTDIR=$out
43     export PREFIX=$out
44     make install
46     substituteInPlace $out/bin/solo5-virtio-mkimage \
47       --replace "/usr/lib/syslinux" "${syslinux}/share/syslinux" \
48       --replace "/usr/share/syslinux" "${syslinux}/share/syslinux" \
49       --replace "cp " "cp --no-preserve=mode "
51     wrapProgram $out/bin/solo5-virtio-mkimage \
52       --prefix PATH : ${lib.makeBinPath [ dosfstools mtools parted syslinux ]}
54     runHook postInstall
55   '';
57   doCheck = stdenv.hostPlatform.isLinux;
58   nativeCheckInputs = [ util-linux qemu_test ];
59   checkPhase = ''
60     runHook preCheck
61     patchShebangs tests
62     substituteInPlace scripts/virtio-run/solo5-virtio-run.sh \
63       --replace " -no-acpi" ""
64     ./tests/bats-core/bats ./tests/tests.bats
65     runHook postCheck
66   '';
68   meta = with lib; {
69     description = "Sandboxed execution environment";
70     homepage = "https://github.com/solo5/solo5";
71     license = licenses.isc;
72     maintainers = [ maintainers.ehmry ];
73     platforms = mapCartesianProduct ({ arch, os }: "${arch}-${os}") {
74       arch = [ "aarch64" "x86_64" ];
75       os = [ "freebsd" "genode" "linux" "openbsd" ];
76     };
77   };