2022-08-21 13:32:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, asciidoctor
|
2022-09-14 18:05:37 +00:00
|
|
|
, buildah
|
|
|
|
, buildah-unwrapped
|
2023-05-24 13:37:59 +00:00
|
|
|
, cargo
|
2022-09-14 18:05:37 +00:00
|
|
|
, libiconv
|
2022-08-21 13:32:41 +00:00
|
|
|
, libkrun
|
2022-09-14 18:05:37 +00:00
|
|
|
, makeWrapper
|
2023-05-24 13:37:59 +00:00
|
|
|
, rustc
|
2022-09-14 18:05:37 +00:00
|
|
|
, sigtool
|
2022-08-21 13:32:41 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "krunvm";
|
2022-12-02 08:20:57 +00:00
|
|
|
version = "0.2.3";
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "containers";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-12-02 08:20:57 +00:00
|
|
|
hash = "sha256-IXofYsOmbrjq8Zq9+a6pvBYsvZFcKzN5IvCuHaxwazI=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
2022-12-02 08:20:57 +00:00
|
|
|
hash = "sha256-Y0FNi/+HuN5SqexHTKjcW6lEaeis7xZDYc2/FOAANIA=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
cargo
|
|
|
|
rustc
|
2022-08-21 13:32:41 +00:00
|
|
|
asciidoctor
|
2022-09-14 18:05:37 +00:00
|
|
|
makeWrapper
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [ sigtool ];
|
2022-08-21 13:32:41 +00:00
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
buildInputs = [ libkrun ] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
];
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
postPatch = ''
|
|
|
|
# do not pollute etc
|
|
|
|
substituteInPlace src/utils.rs \
|
|
|
|
--replace "etc/containers" "share/krunvm/containers"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/krunvm/containers
|
|
|
|
install -D -m755 ${buildah-unwrapped.src}/docs/samples/registries.conf $out/share/krunvm/containers/registries.conf
|
|
|
|
install -D -m755 ${buildah-unwrapped.src}/tests/policy.json $out/share/krunvm/containers/policy.json
|
|
|
|
'';
|
|
|
|
|
|
|
|
# It attaches entitlements with codesign and strip removes those,
|
|
|
|
# voiding the entitlements and making it non-operational.
|
|
|
|
dontStrip = stdenv.isDarwin;
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
wrapProgram $out/bin/krunvm \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ buildah ]} \
|
|
|
|
'';
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A CLI-based utility for creating microVMs from OCI images";
|
|
|
|
homepage = "https://github.com/containers/krunvm";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ nickcao ];
|
2023-02-02 18:25:31 +00:00
|
|
|
platforms = libkrun.meta.platforms;
|
2024-01-02 11:29:13 +00:00
|
|
|
mainProgram = "krunvm";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
}
|