2022-08-21 13:32:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2022-09-14 18:05:37 +00:00
|
|
|
, fetchurl
|
2022-08-21 13:32:41 +00:00
|
|
|
, rustPlatform
|
|
|
|
, pkg-config
|
2022-09-14 18:05:37 +00:00
|
|
|
, dtc
|
2022-08-21 13:32:41 +00:00
|
|
|
, glibc
|
|
|
|
, openssl
|
2022-09-14 18:05:37 +00:00
|
|
|
, libiconv
|
2022-08-21 13:32:41 +00:00
|
|
|
, libkrunfw
|
2022-09-14 18:05:37 +00:00
|
|
|
, Hypervisor
|
2022-08-21 13:32:41 +00:00
|
|
|
, sevVariant ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libkrun";
|
2022-12-02 08:20:57 +00:00
|
|
|
version = "1.4.8";
|
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}";
|
2022-12-02 08:20:57 +00:00
|
|
|
hash = "sha256-3oNsY91hgor1nZV10mcEZyEdhmHlozF8xXaCR4dvLYg=";
|
2022-09-14 18:05:37 +00:00
|
|
|
} else fetchurl {
|
|
|
|
url = "https://github.com/containers/libkrun/releases/download/v${version}/v${version}-with_macos_prebuilts.tar.gz";
|
2022-12-02 08:20:57 +00:00
|
|
|
hash = "sha256-eKjBUianpW4T8OeVwRSEyZFfDE10d3qogkPA4FUJ7rc=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
2022-12-02 08:20:57 +00:00
|
|
|
hash = "sha256-9v8UaBBpQDPZwHVurFJ1FaFMe6wywH3upKDjGcPYnuQ=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
nativeBuildInputs = with rustPlatform; [
|
2022-08-21 13:32:41 +00:00
|
|
|
cargoSetupHook
|
|
|
|
rust.cargo
|
|
|
|
rust.rustc
|
|
|
|
] ++ lib.optional sevVariant pkg-config;
|
|
|
|
|
|
|
|
buildInputs = [
|
2022-09-14 18:05:37 +00:00
|
|
|
(libkrunfw.override { inherit sevVariant; })
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2022-08-21 13:32:41 +00:00
|
|
|
glibc
|
|
|
|
glibc.static
|
2022-09-14 18:05:37 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
Hypervisor
|
|
|
|
dtc
|
2022-08-21 13:32:41 +00:00
|
|
|
] ++ lib.optional sevVariant openssl;
|
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ]
|
|
|
|
++ lib.optional sevVariant "SEV=1";
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -id $out/lib/libkrun.dylib $out/lib/libkrun.${version}.dylib
|
|
|
|
'';
|
|
|
|
|
2022-08-21 13:32:41 +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 ];
|
|
|
|
};
|
|
|
|
}
|