btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / li / libkrun / package.nix
blob0da33d028e1c2d8fb5d6b91c3f7f6b933e60f3c3
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , rustPlatform
5 , cargo
6 , pkg-config
7 , glibc
8 , openssl
9 , libepoxy
10 , libdrm
11 , pipewire
12 , virglrenderer
13 , libkrunfw
14 , llvmPackages
15 , rustc
16 , withGpu ? false
17 , withSound ? false
18 , withNet ? false
19 , sevVariant ? false
22 stdenv.mkDerivation (finalAttrs: {
23   pname = "libkrun";
24   version = "1.9.5";
26   src = fetchFromGitHub {
27     owner = "containers";
28     repo = "libkrun";
29     rev = "refs/tags/v${finalAttrs.version}";
30     hash = "sha256-fVL49g71eyfYyeXI4B1qRNM90fBKjHeq0I4poz1pdME=";
31   };
33   outputs = [ "out" "dev" ];
35   cargoDeps = rustPlatform.fetchCargoTarball {
36     inherit (finalAttrs) src;
37     hash = "sha256-MW4/iB2NsCj0s9Q/h/PoCIIaDfZ/iqw+FGrsJmVR0lw=";
38   };
40   nativeBuildInputs = [
41     llvmPackages.clang
42     rustPlatform.cargoSetupHook
43     cargo
44     rustc
45   ] ++ lib.optional (sevVariant || withGpu) pkg-config;
47   buildInputs = [
48     (libkrunfw.override { inherit sevVariant; })
49     glibc
50     glibc.static
51   ] ++ lib.optionals withGpu [ libepoxy libdrm virglrenderer ]
52     ++ lib.optional withSound pipewire
53     ++ lib.optional sevVariant openssl;
55   env.LIBCLANG_PATH = "${lib.getLib llvmPackages.clang-unwrapped}/lib/libclang.so";
57   makeFlags = [
58     "PREFIX=${placeholder "out"}"
59   ] ++ lib.optional withGpu "GPU=1"
60     ++ lib.optional withSound "SND=1"
61     ++ lib.optional withNet "NET=1"
62     ++ lib.optional sevVariant "SEV=1";
64   postInstall = ''
65     mkdir -p $dev/lib/pkgconfig
66     mv $out/lib64/pkgconfig $dev/lib/pkgconfig
67     mv $out/include $dev/include
68   '';
70   meta = with lib; {
71     description = "Dynamic library providing Virtualization-based process isolation capabilities";
72     homepage = "https://github.com/containers/libkrun";
73     license = licenses.asl20;
74     maintainers = with maintainers; [ nickcao RossComputerGuy ];
75     platforms = libkrunfw.meta.platforms;
76   };