2020-12-13 12:22:45 +00:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
2021-03-11 15:29:18 +00:00
|
|
|
, installShellFiles
|
2020-12-13 12:22:45 +00:00
|
|
|
, buildkit
|
|
|
|
, cni-plugins
|
2021-02-19 09:55:05 +00:00
|
|
|
, extraPackages ? [ ]
|
2020-12-13 12:22:45 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "nerdctl";
|
2021-05-04 12:50:15 +01:00
|
|
|
version = "0.8.1";
|
2020-12-13 12:22:45 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-03-22 08:39:37 +00:00
|
|
|
owner = "containerd";
|
2020-12-13 12:22:45 +00:00
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-05-04 12:50:15 +01:00
|
|
|
sha256 = "sha256-Lu1LJ57jF4lMIfQn/zyT2cc/mkc3RPPlu4gI7qv8blI=";
|
2020-12-13 12:22:45 +00:00
|
|
|
};
|
|
|
|
|
2021-05-04 12:50:15 +01:00
|
|
|
vendorSha256 = "sha256-fEzA/+iKye8lzH4JoXLPqnwjrXPPNuL8gPPbkYJ1glw=";
|
2020-12-13 12:22:45 +00:00
|
|
|
|
2021-03-11 15:29:18 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper installShellFiles ];
|
2020-12-13 12:22:45 +00:00
|
|
|
|
2021-03-22 08:39:37 +00:00
|
|
|
preBuild = let t = "github.com/containerd/nerdctl/pkg/version"; in
|
2021-03-09 18:25:11 +00:00
|
|
|
''
|
|
|
|
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 \
|
2021-02-19 09:55:05 +00:00
|
|
|
--prefix PATH : "${lib.makeBinPath ([ buildkit ] ++ extraPackages)}" \
|
2020-12-13 12:22:45 +00:00
|
|
|
--prefix CNI_PATH : "${cni-plugins}/bin"
|
2021-03-11 15:29:18 +00:00
|
|
|
|
|
|
|
installShellCompletion --cmd nerdctl \
|
|
|
|
--bash <($out/bin/nerdctl completion bash)
|
2020-12-13 12:22:45 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-19 09:55:05 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
$out/bin/nerdctl --help
|
2021-03-11 15:29:18 +00:00
|
|
|
$out/bin/nerdctl --version | grep "nerdctl version ${version}"
|
2021-02-19 09:55:05 +00:00
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2020-12-13 12:22:45 +00:00
|
|
|
meta = with lib; {
|
2021-03-22 08:39:37 +00:00
|
|
|
homepage = "https://github.com/containerd/nerdctl/";
|
|
|
|
changelog = "https://github.com/containerd/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 ];
|
2021-02-19 09:55:05 +00:00
|
|
|
platforms = platforms.linux;
|
2020-12-13 12:22:45 +00:00
|
|
|
};
|
|
|
|
}
|