1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/applications/networking/cluster/nerdctl/default.nix

63 lines
1.6 KiB
Nix
Raw Normal View History

2020-12-13 12:22:45 +00:00
{ lib
, buildGoModule
, fetchFromGitHub
, makeWrapper
, buildkit
, cni-plugins
, extraPackages ? [ ]
2020-12-13 12:22:45 +00:00
}:
buildGoModule rec {
pname = "nerdctl";
version = "0.7.0";
2020-12-13 12:22:45 +00:00
src = fetchFromGitHub {
owner = "AkihiroSuda";
repo = pname;
rev = "v${version}";
sha256 = "sha256-z5Ekryaa5KMShrjdsmFk9bXahtuc+6tec7dxH5/w7+A=";
2020-12-13 12:22:45 +00:00
};
vendorSha256 = "sha256-ovmVNtzTQbg141IvbaF/+k5WHxX8wuK7z5gH9l2g5UE=";
2020-12-13 12:22:45 +00:00
nativeBuildInputs = [ makeWrapper ];
preBuild =
let
t = "github.com/AkihiroSuda/nerdctl/pkg/version";
in
''
buildFlagsArray+=("-ldflags" "-s -w -X ${t}.Version=v${version} -X ${t}.Revision=<unknown>")
'';
2020-12-13 12:22:45 +00:00
2021-02-22 13:18:59 +00:00
# Many checks require a containerd socket and running nerdctl after it's built
doCheck = false;
2020-12-13 12:22:45 +00:00
postInstall = ''
wrapProgram $out/bin/nerdctl \
--prefix PATH : "${lib.makeBinPath ([ buildkit ] ++ extraPackages)}" \
2020-12-13 12:22:45 +00:00
--prefix CNI_PATH : "${cni-plugins}/bin"
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
2021-02-22 13:18:59 +00:00
# nerdctl expects XDG_RUNTIME_DIR to be set
export XDG_RUNTIME_DIR=$TMPDIR
$out/bin/nerdctl --help
# --version will error without containerd.sock access
$out/bin/nerdctl --help | grep "${version}"
runHook postInstallCheck
'';
2020-12-13 12:22:45 +00:00
meta = with lib; {
homepage = "https://github.com/AkihiroSuda/nerdctl/";
changelog = "https://github.com/AkihiroSuda/nerdctl/releases/tag/v${version}";
2020-12-13 12:22:45 +00:00
description = "A Docker-compatible CLI for containerd";
license = licenses.asl20;
maintainers = with maintainers; [ jk ];
platforms = platforms.linux;
2020-12-13 12:22:45 +00:00
};
}