lol
1{ lib
2, buildGoModule
3, fetchFromGitHub
4, makeWrapper
5, installShellFiles
6, buildkit
7, cni-plugins
8, extraPackages ? [ ]
9}:
10
11buildGoModule rec {
12 pname = "nerdctl";
13 version = "0.13.0";
14
15 src = fetchFromGitHub {
16 owner = "containerd";
17 repo = pname;
18 rev = "v${version}";
19 sha256 = "sha256-uyLY2yH/6J0rtra0brBATadPqrNyyuCcaGfOrng9h4Y=";
20 };
21
22 vendorSha256 = "sha256-r7xzvntTIJocdYMQpFXunI2XV65eRG+piEEzS5N2xsY=";
23
24 nativeBuildInputs = [ makeWrapper installShellFiles ];
25
26 ldflags = let t = "github.com/containerd/nerdctl/pkg/version"; in
27 [ "-s" "-w" "-X ${t}.Version=v${version}" "-X ${t}.Revision=<unknown>" ];
28
29 # Many checks require a containerd socket and running nerdctl after it's built
30 doCheck = false;
31
32 postInstall = ''
33 wrapProgram $out/bin/nerdctl \
34 --prefix PATH : "${lib.makeBinPath ([ buildkit ] ++ extraPackages)}" \
35 --prefix CNI_PATH : "${cni-plugins}/bin"
36
37 installShellCompletion --cmd nerdctl \
38 --bash <($out/bin/nerdctl completion bash) \
39 --fish <($out/bin/nerdctl completion fish) \
40 --zsh <($out/bin/nerdctl completion zsh)
41 '';
42
43 doInstallCheck = true;
44 installCheckPhase = ''
45 runHook preInstallCheck
46 $out/bin/nerdctl --help
47 $out/bin/nerdctl --version | grep "nerdctl version ${version}"
48 runHook postInstallCheck
49 '';
50
51 meta = with lib; {
52 homepage = "https://github.com/containerd/nerdctl/";
53 changelog = "https://github.com/containerd/nerdctl/releases/tag/v${version}";
54 description = "A Docker-compatible CLI for containerd";
55 license = licenses.asl20;
56 maintainers = with maintainers; [ jk ];
57 platforms = platforms.linux;
58 };
59}