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";
|
2023-02-02 18:25:31 +00:00
|
|
|
version = "1.5.0";
|
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}";
|
2023-02-02 18:25:31 +00:00
|
|
|
hash = "sha256-3WYxGpZ3uRbnh/VEDVSNOxp25SE7GQgC5t3ROuKNRE0=";
|
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";
|
2023-02-02 18:25:31 +00:00
|
|
|
hash = "sha256-T1nYzrzxEJaVBnI00CQPKoT2OYJxdW7y6WNkabNsQYI=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
2023-02-02 18:25:31 +00:00
|
|
|
hash = "sha256-Clb6PNwLuzx42Qr1tgpjG1WHq9NcDr2bbfnyp4UVVLU=";
|
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 ];
|
2023-02-02 18:25:31 +00:00
|
|
|
platforms = libkrunfw.meta.platforms;
|
|
|
|
sourceProvenance = with sourceTypes; lib.optionals stdenv.isDarwin [ binaryNativeCode ];
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
}
|