nixpkgs/pkgs/applications/networking/cluster/nerdctl/default.nix
06kellyjac b8e095cb10 nerdctl: 0.7.1 -> 0.7.2
- nerdctl moved to containerd org
- XDG_RUNTIME_DIRS no longer needed for --version or completion
2021-03-22 08:39:37 +00:00

60 lines
1.6 KiB
Nix

{ lib
, buildGoModule
, fetchFromGitHub
, makeWrapper
, installShellFiles
, buildkit
, cni-plugins
, extraPackages ? [ ]
}:
buildGoModule rec {
pname = "nerdctl";
version = "0.7.2";
src = fetchFromGitHub {
owner = "containerd";
repo = pname;
rev = "v${version}";
sha256 = "sha256-0q3UmlXzW0fGYPc1IptuIbCMnKW4pyDm1KxkRqU2voA=";
};
vendorSha256 = "sha256-QVvID9rrOFngL94LWN75HSnyTgh3F0KaScWxMIKUqDM=";
nativeBuildInputs = [ makeWrapper installShellFiles ];
preBuild = let t = "github.com/containerd/nerdctl/pkg/version"; in
''
buildFlagsArray+=("-ldflags" "-s -w -X ${t}.Version=v${version} -X ${t}.Revision=<unknown>")
'';
# Many checks require a containerd socket and running nerdctl after it's built
doCheck = false;
postInstall = ''
wrapProgram $out/bin/nerdctl \
--prefix PATH : "${lib.makeBinPath ([ buildkit ] ++ extraPackages)}" \
--prefix CNI_PATH : "${cni-plugins}/bin"
installShellCompletion --cmd nerdctl \
--bash <($out/bin/nerdctl completion bash)
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/nerdctl --help
$out/bin/nerdctl --version | grep "nerdctl version ${version}"
runHook postInstallCheck
'';
meta = with lib; {
homepage = "https://github.com/containerd/nerdctl/";
changelog = "https://github.com/containerd/nerdctl/releases/tag/v${version}";
description = "A Docker-compatible CLI for containerd";
license = licenses.asl20;
maintainers = with maintainers; [ jk ];
platforms = platforms.linux;
};
}