1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00

Merge pull request #321359 from ExpidusOS/feat/krun

krun: init at 0-unstable-2024-06-18
This commit is contained in:
tomberek 2024-07-23 22:48:19 -04:00 committed by GitHub
commit 69c850c2db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 118 additions and 23 deletions

View file

@ -0,0 +1,70 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, rustPlatform
, libiconv
, libkrun
, makeWrapper
, passt
, sommelier
, mesa
, opengl-driver ? mesa.drivers
, withSommelier ? false
}:
rustPlatform.buildRustPackage rec {
pname = "krun";
version = "0-unstable-2024-06-18";
src = fetchFromGitHub {
owner = "slp";
repo = pname;
rev = "912afa5c6525b7c8f83dffd65ec4b1425b3f7521";
hash = "sha256-rDuxv3UakAemDnj4Nsbpqsykts2IcseuQmDwO24L+u8=";
};
patches = [
(fetchpatch {
url = "https://github.com/slp/krun/pull/39.diff";
hash = "sha256-CV69L+VDDLRcWgpgDCAYKLlTU9ytFcHhzNgOibWD8KY=";
})
(fetchpatch {
url = "https://github.com/slp/krun/pull/38.diff";
hash = "sha256-cK3iDhh+33H16V65lWUXahjmpSxI1HhiLUmkjfkRB7A=";
})
];
cargoHash = "sha256-NahnigxJaY2QwWnySCRrnf3JyqZ+7jRA1CpE7ON0OOE=";
nativeBuildInputs = [
rustPlatform.bindgenHook
makeWrapper
];
buildInputs = [
(libkrun.override {
withGpu = true;
withNet = true;
})
];
# Allow for sommelier to be disabled as it can cause problems.
wrapArgs = [
"--prefix PATH : ${lib.makeBinPath (lib.optional withSommelier [ sommelier ] ++ [ passt ])}"
];
postFixup = ''
wrapProgram $out/bin/krun $wrapArgs \
--set-default OPENGL_DRIVER ${opengl-driver}
'';
meta = {
description = "Run programs from your system in a microVM";
homepage = "https://github.com/slp/krun";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ RossComputerGuy ];
platforms = libkrun.meta.platforms;
mainProgram = "krun";
};
}

View file

@ -6,54 +6,72 @@
, pkg-config
, glibc
, openssl
, libepoxy
, libdrm
, pipewire
, virglrenderer
, libkrunfw
, llvmPackages
, rustc
, withGpu ? false
, withSound ? false
, withNet ? false
, sevVariant ? false
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "libkrun";
version = "1.9.3";
src = fetchFromGitHub {
owner = "containers";
repo = "libkrun";
rev = "refs/tags/v${version}";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-LIp2/794gbHPweBJcHCjbF0m+bJAs0SPF7WivW7fxLI=";
};
outputs = [ "out" "dev" ];
cargoDeps = rustPlatform.fetchCargoTarball {
inherit pname version src;
inherit (finalAttrs) pname version src;
hash = "sha256-g4ceYi16mjEgvWTAQEW8ShT/e5IKnlgLgk49Mg0N2fQ=";
};
nativeBuildInputs = [
llvmPackages.clang
rustPlatform.cargoSetupHook
cargo
rustc
] ++ lib.optionals sevVariant [
pkg-config
];
] ++ lib.optional (sevVariant || withGpu) pkg-config;
buildInputs = [
(libkrunfw.override { inherit sevVariant; })
glibc
glibc.static
] ++ lib.optionals sevVariant [
openssl
];
] ++ lib.optionals withGpu [ libepoxy libdrm virglrenderer ]
++ lib.optional withSound pipewire
++ lib.optional sevVariant openssl;
env.LIBCLANG_PATH = "${llvmPackages.clang-unwrapped.lib}/lib/libclang.so";
makeFlags = [
"PREFIX=${placeholder "out"}"
] ++ lib.optionals sevVariant [
"SEV=1"
];
] ++ lib.optional withGpu "GPU=1"
++ lib.optional withSound "SND=1"
++ lib.optional withNet "NET=1"
++ lib.optional sevVariant "SEV=1";
postInstall = ''
mkdir -p $dev/lib/pkgconfig
mv $out/lib64/pkgconfig $dev/lib/pkgconfig
mv $out/include $dev/include
'';
meta = with lib; {
description = "Dynamic library providing Virtualization-based process isolation capabilities";
homepage = "https://github.com/containers/libkrun";
license = licenses.asl20;
maintainers = with maintainers; [ nickcao ];
maintainers = with maintainers; [ nickcao RossComputerGuy ];
platforms = libkrunfw.meta.platforms;
};
}
})

View file

@ -5,25 +5,27 @@
, flex
, bison
, bc
, cpio
, perl
, elfutils
, python3
, sevVariant ? false
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "libkrunfw";
version = "4.0.0";
version = "4.0.0-unstable-2024-06-10";
src = fetchFromGitHub {
owner = "containers";
repo = "libkrunfw";
rev = "refs/tags/v${version}";
hash = "sha256-9oVl4mlJE7QHeehG86pbh7KdShZNUGwlnO75k/F/PQ0=";
rev = "12236fa4caa42423ff3081b6179aa0a5f37c67c9";
hash = "sha256-Vcbg2zBVMQsiAQF/cEEIRMqppMBVGnqUBlDquGzRBsc=";
};
kernelSrc = fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.7.tar.xz";
hash = "sha256-3hQ8th3Kp1bAX1b/NRRDFtgQYVgZUYoz40dU8GTEp9g=";
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.32.tar.xz";
hash = "sha256-qqgk6vB/YZEdIrdf8JCkA8PdC9c+I5M+C7qLWXFDbOE=";
};
postPatch = ''
@ -35,6 +37,8 @@ stdenv.mkDerivation rec {
flex
bison
bc
cpio
perl
python3
python3.pkgs.pyelftools
];
@ -49,13 +53,16 @@ stdenv.mkDerivation rec {
"SEV=1"
];
# Fixes https://github.com/containers/libkrunfw/issues/55
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.targetPlatform.isAarch64 "-march=armv8-a+crypto";
enableParallelBuilding = true;
meta = with lib; {
description = "Dynamic library bundling the guest payload consumed by libkrun";
homepage = "https://github.com/containers/libkrunfw";
license = with licenses; [ lgpl2Only lgpl21Only ];
maintainers = with maintainers; [ nickcao ];
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ nickcao RossComputerGuy ];
platforms = [ "x86_64-linux" "aarch64-linux" ];
};
}
})