2022-08-13 11:43:05 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2022-08-16 18:46:05 +02:00
|
|
|
, fetchurl
|
2022-08-13 11:43:05 +02:00
|
|
|
, rustPlatform
|
|
|
|
, pkg-config
|
2022-08-16 18:46:05 +02:00
|
|
|
, dtc
|
2022-08-13 11:43:05 +02:00
|
|
|
, glibc
|
|
|
|
, openssl
|
2022-08-16 18:46:05 +02:00
|
|
|
, libiconv
|
2022-08-13 11:43:05 +02:00
|
|
|
, libkrunfw
|
2022-08-16 18:46:05 +02:00
|
|
|
, Hypervisor
|
2022-08-13 11:43:05 +02:00
|
|
|
, sevVariant ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libkrun";
|
|
|
|
version = "1.3.0";
|
|
|
|
|
2022-08-16 18:46:05 +02:00
|
|
|
src = if stdenv.isLinux then fetchFromGitHub {
|
2022-08-13 11:43:05 +02:00
|
|
|
owner = "containers";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-qVyEqiqaQ8wfZhL5u+Bsaa1yXlgHUitSj5bo7FJ5Y8c=";
|
2022-08-16 18:46:05 +02:00
|
|
|
} else fetchurl {
|
|
|
|
url = "https://github.com/containers/libkrun/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz";
|
|
|
|
hash = "sha256-RBqeGUhB6Sdt+JujyQBW/76mZwnT0LNs9AMYr8+OCVU=";
|
2022-08-13 11:43:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
hash = "sha256-jxSzhj1iU8qY+sZEVCYTaUqpaA4egjJi9qxrapASQF0=";
|
|
|
|
};
|
|
|
|
|
2022-08-16 18:46:05 +02:00
|
|
|
nativeBuildInputs = with rustPlatform; [
|
2022-08-13 11:43:05 +02:00
|
|
|
cargoSetupHook
|
|
|
|
rust.cargo
|
|
|
|
rust.rustc
|
|
|
|
] ++ lib.optional sevVariant pkg-config;
|
|
|
|
|
|
|
|
buildInputs = [
|
2022-08-16 18:46:05 +02:00
|
|
|
(libkrunfw.override { inherit sevVariant; })
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2022-08-13 11:43:05 +02:00
|
|
|
glibc
|
|
|
|
glibc.static
|
2022-08-16 18:46:05 +02:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
Hypervisor
|
|
|
|
dtc
|
2022-08-13 11:43:05 +02:00
|
|
|
] ++ lib.optional sevVariant openssl;
|
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ]
|
|
|
|
++ lib.optional sevVariant "SEV=1";
|
|
|
|
|
2022-08-16 18:46:05 +02:00
|
|
|
postFixup = lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/libkrun.dylib $out/lib/libkrun.${version}.dylib
|
|
|
|
'';
|
|
|
|
|
2022-08-13 11:43:05 +02: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 ];
|
|
|
|
};
|
|
|
|
}
|