2022-08-13 09:43:05 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2022-08-16 16:46:05 +00:00
|
|
|
, fetchurl
|
2022-08-13 09:43:05 +00:00
|
|
|
, rustPlatform
|
2023-05-12 14:17:16 +00:00
|
|
|
, cargo
|
2022-08-13 09:43:05 +00:00
|
|
|
, pkg-config
|
2022-08-16 16:46:05 +00:00
|
|
|
, dtc
|
2022-08-13 09:43:05 +00:00
|
|
|
, glibc
|
|
|
|
, openssl
|
2022-08-16 16:46:05 +00:00
|
|
|
, libiconv
|
2022-08-13 09:43:05 +00:00
|
|
|
, libkrunfw
|
2023-05-12 14:17:16 +00:00
|
|
|
, rustc
|
2022-08-16 16:46:05 +00:00
|
|
|
, Hypervisor
|
2022-08-13 09:43:05 +00:00
|
|
|
, sevVariant ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libkrun";
|
2023-03-21 01:57:34 +00:00
|
|
|
version = "1.5.1";
|
2022-08-13 09:43:05 +00:00
|
|
|
|
2022-08-16 16:46:05 +00:00
|
|
|
src = if stdenv.isLinux then fetchFromGitHub {
|
2022-08-13 09:43:05 +00:00
|
|
|
owner = "containers";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-03-21 01:57:34 +00:00
|
|
|
hash = "sha256-N9AkG+zkjQHNaaCVrEpMfWUN9bQNHjMA2xi5NUulF5A=";
|
2022-08-16 16:46:05 +00:00
|
|
|
} else fetchurl {
|
|
|
|
url = "https://github.com/containers/libkrun/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz";
|
2023-03-21 01:57:34 +00:00
|
|
|
hash = "sha256-8hPbnZtDbiVdwBrtxt4nZ/QA2OFtui2VsQlaoOmWybo=";
|
2022-08-13 09:43:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
2023-03-21 01:57:34 +00:00
|
|
|
hash = "sha256-nbtp7FP+ObVGfDOEzTt4Z7TZwcNlREczTKIAXGSflZU=";
|
2022-08-13 09:43:05 +00:00
|
|
|
};
|
|
|
|
|
2023-05-12 14:17:16 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
cargo
|
|
|
|
rustc
|
2022-08-13 09:43:05 +00:00
|
|
|
] ++ lib.optional sevVariant pkg-config;
|
|
|
|
|
|
|
|
buildInputs = [
|
2022-08-16 16:46:05 +00:00
|
|
|
(libkrunfw.override { inherit sevVariant; })
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2022-08-13 09:43:05 +00:00
|
|
|
glibc
|
|
|
|
glibc.static
|
2022-08-16 16:46:05 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
Hypervisor
|
|
|
|
dtc
|
2022-08-13 09:43:05 +00:00
|
|
|
] ++ lib.optional sevVariant openssl;
|
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ]
|
|
|
|
++ lib.optional sevVariant "SEV=1";
|
|
|
|
|
2022-08-16 16:46:05 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/libkrun.dylib $out/lib/libkrun.${version}.dylib
|
|
|
|
'';
|
|
|
|
|
2022-08-13 09:43:05 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A dynamic library providing Virtualization-based process isolation capabilities";
|
|
|
|
homepage = "https://github.com/containers/libkrun";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ nickcao ];
|
2023-01-21 06:18:26 +00:00
|
|
|
platforms = libkrunfw.meta.platforms;
|
|
|
|
sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ];
|
2022-08-13 09:43:05 +00:00
|
|
|
};
|
|
|
|
}
|