Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.05 69 lines 1.8 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, fetchurl 5, rustPlatform 6, cargo 7, pkg-config 8, dtc 9, glibc 10, openssl 11, libiconv 12, libkrunfw 13, rustc 14, Hypervisor 15, sevVariant ? false 16}: 17 18stdenv.mkDerivation rec { 19 pname = "libkrun"; 20 version = "1.5.1"; 21 22 src = if stdenv.isLinux then fetchFromGitHub { 23 owner = "containers"; 24 repo = pname; 25 rev = "v${version}"; 26 hash = "sha256-N9AkG+zkjQHNaaCVrEpMfWUN9bQNHjMA2xi5NUulF5A="; 27 } else fetchurl { 28 url = "https://github.com/containers/libkrun/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz"; 29 hash = "sha256-8hPbnZtDbiVdwBrtxt4nZ/QA2OFtui2VsQlaoOmWybo="; 30 }; 31 32 cargoDeps = rustPlatform.fetchCargoTarball { 33 inherit src; 34 hash = "sha256-nbtp7FP+ObVGfDOEzTt4Z7TZwcNlREczTKIAXGSflZU="; 35 }; 36 37 nativeBuildInputs = [ 38 rustPlatform.cargoSetupHook 39 cargo 40 rustc 41 ] ++ lib.optional sevVariant pkg-config; 42 43 buildInputs = [ 44 (libkrunfw.override { inherit sevVariant; }) 45 ] ++ lib.optionals stdenv.isLinux [ 46 glibc 47 glibc.static 48 ] ++ lib.optionals stdenv.isDarwin [ 49 libiconv 50 Hypervisor 51 dtc 52 ] ++ lib.optional sevVariant openssl; 53 54 makeFlags = [ "PREFIX=${placeholder "out"}" ] 55 ++ lib.optional sevVariant "SEV=1"; 56 57 postFixup = lib.optionalString stdenv.isDarwin '' 58 install_name_tool -id $out/lib/libkrun.dylib $out/lib/libkrun.${version}.dylib 59 ''; 60 61 meta = with lib; { 62 description = "A dynamic library providing Virtualization-based process isolation capabilities"; 63 homepage = "https://github.com/containers/libkrun"; 64 license = licenses.asl20; 65 maintainers = with maintainers; [ nickcao ]; 66 platforms = libkrunfw.meta.platforms; 67 sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ]; 68 }; 69}