Merge pull request #276738 from NickCao/krun

libkrunfw: 3.11.0 -> 4.0.0, libkrun: 1.5.1 -> 1.7.2
This commit is contained in:
Nick Cao 2023-12-26 17:20:06 -05:00 committed by GitHub
commit d956588517
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 51 deletions

View file

@ -1,62 +1,53 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchurl
, rustPlatform
, cargo
, pkg-config
, dtc
, glibc
, openssl
, libiconv
, libkrunfw
, rustc
, Hypervisor
, sevVariant ? false
}:
stdenv.mkDerivation rec {
pname = "libkrun";
version = "1.5.1";
version = "1.7.2";
src = if stdenv.isLinux then fetchFromGitHub {
src = fetchFromGitHub {
owner = "containers";
repo = pname;
rev = "v${version}";
hash = "sha256-N9AkG+zkjQHNaaCVrEpMfWUN9bQNHjMA2xi5NUulF5A=";
} else fetchurl {
url = "https://github.com/containers/libkrun/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz";
hash = "sha256-8hPbnZtDbiVdwBrtxt4nZ/QA2OFtui2VsQlaoOmWybo=";
repo = "libkrun";
rev = "refs/tags/v${version}";
hash = "sha256-cP+Pxl/9QIsoGysXTBZJ86q57cIMA7TJenMWtcOI+Y4=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
hash = "sha256-nbtp7FP+ObVGfDOEzTt4Z7TZwcNlREczTKIAXGSflZU=";
inherit pname version src;
hash = "sha256-qVyHC015QJEt6LZ8br3H0nucYKhYGBMtyB2IBaixTqk=";
};
nativeBuildInputs = [
rustPlatform.cargoSetupHook
cargo
rustc
] ++ lib.optional sevVariant pkg-config;
] ++ lib.optionals sevVariant [
pkg-config
];
buildInputs = [
(libkrunfw.override { inherit sevVariant; })
] ++ lib.optionals stdenv.isLinux [
glibc
glibc.static
] ++ lib.optionals stdenv.isDarwin [
libiconv
Hypervisor
dtc
] ++ lib.optional sevVariant openssl;
] ++ lib.optionals sevVariant [
openssl
];
makeFlags = [ "PREFIX=${placeholder "out"}" ]
++ lib.optional sevVariant "SEV=1";
postFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool -id $out/lib/libkrun.dylib $out/lib/libkrun.${version}.dylib
'';
makeFlags = [
"PREFIX=${placeholder "out"}"
] ++ lib.optionals sevVariant [
"SEV=1"
];
meta = with lib; {
description = "A dynamic library providing Virtualization-based process isolation capabilities";
@ -64,6 +55,5 @@ stdenv.mkDerivation rec {
license = licenses.asl20;
maintainers = with maintainers; [ nickcao ];
platforms = libkrunfw.meta.platforms;
sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ];
};
}

View file

@ -10,39 +10,44 @@
, sevVariant ? false
}:
assert sevVariant -> stdenv.isx86_64;
stdenv.mkDerivation rec {
pname = "libkrunfw";
version = "3.11.0";
version = "4.0.0";
src = if stdenv.isLinux then fetchFromGitHub {
src = fetchFromGitHub {
owner = "containers";
repo = pname;
rev = "v${version}";
hash = "sha256-p5z3Dc7o/Ja3K0VlOWIPc0qOIU5p+JSxWe7QiVQNkjs=";
} else fetchurl {
url = "https://github.com/containers/libkrunfw/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz";
hash = "sha256-XcdsK8L5NwMgelSMhE2YKYxaAin/3p/+GrljGGZpK5Y=";
repo = "libkrunfw";
rev = "refs/tags/v${version}";
hash = "sha256-9oVl4mlJE7QHeehG86pbh7KdShZNUGwlnO75k/F/PQ0=";
};
kernelSrc = fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.2.9.tar.xz";
hash = "sha256-kDRJwWTAPw50KqzJIOGFY1heB6KMbLeeD9bDZpX9Q/U=";
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.7.tar.xz";
hash = "sha256-3hQ8th3Kp1bAX1b/NRRDFtgQYVgZUYoz40dU8GTEp9g=";
};
preBuild = ''
postPatch = ''
substituteInPlace Makefile \
--replace 'curl $(KERNEL_REMOTE) -o $(KERNEL_TARBALL)' 'ln -s $(kernelSrc) $(KERNEL_TARBALL)' \
--replace 'gcc' '$(CC)'
--replace 'curl $(KERNEL_REMOTE) -o $(KERNEL_TARBALL)' 'ln -s $(kernelSrc) $(KERNEL_TARBALL)'
'';
nativeBuildInputs = [ flex bison bc python3 python3.pkgs.pyelftools ];
buildInputs = lib.optionals stdenv.isLinux [ elfutils ];
nativeBuildInputs = [
flex
bison
bc
python3
python3.pkgs.pyelftools
];
buildInputs = [
elfutils
];
makeFlags = [
"PREFIX=${placeholder "out"}"
"SONAME_Darwin=-Wl,-install_name,${placeholder "out"}/lib/libkrunfw.dylib"
] ++ lib.optional sevVariant "SEV=1";
] ++ lib.optionals sevVariant [
"SEV=1"
];
enableParallelBuilding = true;
@ -51,7 +56,6 @@ stdenv.mkDerivation rec {
homepage = "https://github.com/containers/libkrunfw";
license = with licenses; [ lgpl2Only lgpl21Only ];
maintainers = with maintainers; [ nickcao ];
platforms = [ "x86_64-linux" "aarch64-darwin" ];
sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ];
platforms = [ "x86_64-linux" ];
};
}

View file

@ -28059,9 +28059,7 @@ with pkgs;
libdatachannel = callPackage ../development/libraries/libdatachannel { };
libkrun = callPackage ../development/libraries/libkrun {
inherit (darwin.apple_sdk.frameworks) Hypervisor;
};
libkrun = callPackage ../development/libraries/libkrun { };
libkrun-sev = libkrun.override { sevVariant = true; };