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

View file

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

View file

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