at 24.05-pre 57 lines 1.7 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, fetchurl 5, flex 6, bison 7, bc 8, elfutils 9, python3 10, sevVariant ? false 11}: 12 13assert sevVariant -> stdenv.isx86_64; 14stdenv.mkDerivation rec { 15 pname = "libkrunfw"; 16 version = "3.11.0"; 17 18 src = if stdenv.isLinux then fetchFromGitHub { 19 owner = "containers"; 20 repo = pname; 21 rev = "v${version}"; 22 hash = "sha256-p5z3Dc7o/Ja3K0VlOWIPc0qOIU5p+JSxWe7QiVQNkjs="; 23 } else fetchurl { 24 url = "https://github.com/containers/libkrunfw/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz"; 25 hash = "sha256-XcdsK8L5NwMgelSMhE2YKYxaAin/3p/+GrljGGZpK5Y="; 26 }; 27 28 kernelSrc = fetchurl { 29 url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.2.9.tar.xz"; 30 hash = "sha256-kDRJwWTAPw50KqzJIOGFY1heB6KMbLeeD9bDZpX9Q/U="; 31 }; 32 33 preBuild = '' 34 substituteInPlace Makefile \ 35 --replace 'curl $(KERNEL_REMOTE) -o $(KERNEL_TARBALL)' 'ln -s $(kernelSrc) $(KERNEL_TARBALL)' \ 36 --replace 'gcc' '$(CC)' 37 ''; 38 39 nativeBuildInputs = [ flex bison bc python3 python3.pkgs.pyelftools ]; 40 buildInputs = lib.optionals stdenv.isLinux [ elfutils ]; 41 42 makeFlags = [ 43 "PREFIX=${placeholder "out"}" 44 "SONAME_Darwin=-Wl,-install_name,${placeholder "out"}/lib/libkrunfw.dylib" 45 ] ++ lib.optional sevVariant "SEV=1"; 46 47 enableParallelBuilding = true; 48 49 meta = with lib; { 50 description = "A dynamic library bundling the guest payload consumed by libkrun"; 51 homepage = "https://github.com/containers/libkrunfw"; 52 license = with licenses; [ lgpl2Only lgpl21Only ]; 53 maintainers = with maintainers; [ nickcao ]; 54 platforms = [ "x86_64-linux" "aarch64-darwin" ]; 55 sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ]; 56 }; 57}