2020-12-13 12:22:45 +00:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, 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-02-24 09:36:39 +00:00
|
|
|
version = "0.6.1";
|
2020-12-13 12:22:45 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "AkihiroSuda";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-02-24 09:36:39 +00:00
|
|
|
sha256 = "sha256-zexvTPEQw7iW1d3ahHmqTn+UaT/bJMlr1sVlWErc2ck=";
|
2020-12-13 12:22:45 +00:00
|
|
|
};
|
|
|
|
|
2021-02-22 13:18:59 +00:00
|
|
|
vendorSha256 = "sha256-bX1GfKbAbdEAnW3kPNsbF/cJWufxvuhm//G88qJ3u08=";
|
2020-12-13 12:22:45 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildFlagsArray = [
|
|
|
|
"-ldflags="
|
|
|
|
"-w"
|
|
|
|
"-s"
|
|
|
|
"-X github.com/AkihiroSuda/nerdctl/pkg/version.Version=v${version}"
|
|
|
|
"-X github.com/AkihiroSuda/nerdctl/pkg/version.Revision=<unknown>"
|
|
|
|
];
|
|
|
|
|
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-02-19 09:55:05 +00:00
|
|
|
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
|
|
|
|
|
2021-02-19 09:55:05 +00:00
|
|
|
$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; {
|
2021-02-19 09:55:05 +00:00
|
|
|
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 ];
|
2021-02-19 09:55:05 +00:00
|
|
|
platforms = platforms.linux;
|
2020-12-13 12:22:45 +00:00
|
|
|
};
|
|
|
|
}
|