mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 17:14:33 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
76 lines
1.8 KiB
Nix
76 lines
1.8 KiB
Nix
{ lib
|
|
, stdenv
|
|
, rustPlatform
|
|
, fetchFromGitHub
|
|
, asciidoctor
|
|
, buildah
|
|
, buildah-unwrapped
|
|
, cargo
|
|
, libiconv
|
|
, libkrun
|
|
, makeWrapper
|
|
, rustc
|
|
, sigtool
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "krunvm";
|
|
version = "0.2.3";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "containers";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
hash = "sha256-IXofYsOmbrjq8Zq9+a6pvBYsvZFcKzN5IvCuHaxwazI=";
|
|
};
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
inherit src;
|
|
hash = "sha256-Y0FNi/+HuN5SqexHTKjcW6lEaeis7xZDYc2/FOAANIA=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
rustPlatform.cargoSetupHook
|
|
cargo
|
|
rustc
|
|
asciidoctor
|
|
makeWrapper
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ sigtool ];
|
|
|
|
buildInputs = [ libkrun ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
libiconv
|
|
];
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
|
|
|
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.hostPlatform.isDarwin;
|
|
|
|
postFixup = ''
|
|
wrapProgram $out/bin/krunvm \
|
|
--prefix PATH : ${lib.makeBinPath [ buildah ]} \
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "CLI-based utility for creating microVMs from OCI images";
|
|
homepage = "https://github.com/containers/krunvm";
|
|
license = licenses.asl20;
|
|
maintainers = with maintainers; [ nickcao ];
|
|
platforms = libkrun.meta.platforms;
|
|
mainProgram = "krunvm";
|
|
};
|
|
}
|