2022-08-21 13:32:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchurl
|
|
|
|
, flex
|
|
|
|
, bison
|
|
|
|
, bc
|
|
|
|
, elfutils
|
|
|
|
, python3
|
|
|
|
, sevVariant ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert sevVariant -> stdenv.isx86_64;
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libkrunfw";
|
2023-04-12 12:48:02 +00:00
|
|
|
version = "3.11.0";
|
2022-08-21 13:32:41 +00:00
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
src = if stdenv.isLinux then fetchFromGitHub {
|
2022-08-21 13:32:41 +00:00
|
|
|
owner = "containers";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-04-12 12:48:02 +00:00
|
|
|
hash = "sha256-p5z3Dc7o/Ja3K0VlOWIPc0qOIU5p+JSxWe7QiVQNkjs=";
|
2022-09-14 18:05:37 +00:00
|
|
|
} else fetchurl {
|
|
|
|
url = "https://github.com/containers/libkrunfw/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz";
|
2023-04-12 12:48:02 +00:00
|
|
|
hash = "sha256-XcdsK8L5NwMgelSMhE2YKYxaAin/3p/+GrljGGZpK5Y=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
kernelSrc = fetchurl {
|
2023-04-12 12:48:02 +00:00
|
|
|
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.2.9.tar.xz";
|
|
|
|
hash = "sha256-kDRJwWTAPw50KqzJIOGFY1heB6KMbLeeD9bDZpX9Q/U=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
preBuild = ''
|
2022-09-14 18:05:37 +00:00
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace 'curl $(KERNEL_REMOTE) -o $(KERNEL_TARBALL)' 'ln -s $(kernelSrc) $(KERNEL_TARBALL)' \
|
|
|
|
--replace 'gcc' '$(CC)'
|
2022-08-21 13:32:41 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ flex bison bc python3 python3.pkgs.pyelftools ];
|
2022-09-14 18:05:37 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isLinux [ elfutils ];
|
2022-08-21 13:32:41 +00:00
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=${placeholder "out"}"
|
|
|
|
"SONAME_Darwin=-Wl,-install_name,${placeholder "out"}/lib/libkrunfw.dylib"
|
|
|
|
] ++ lib.optional sevVariant "SEV=1";
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A dynamic library bundling the guest payload consumed by libkrun";
|
|
|
|
homepage = "https://github.com/containers/libkrunfw";
|
|
|
|
license = with licenses; [ lgpl2Only lgpl21Only ];
|
|
|
|
maintainers = with maintainers; [ nickcao ];
|
2022-12-02 08:20:57 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-darwin" ];
|
2023-02-02 18:25:31 +00:00
|
|
|
sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ];
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
}
|