Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 makeWrapper,
6 installShellFiles,
7 buildkit,
8 cni-plugins,
9 extraPackages ? [ ],
10}:
11
12buildGoModule rec {
13 pname = "nerdctl";
14 version = "1.7.7";
15
16 src = fetchFromGitHub {
17 owner = "containerd";
18 repo = "nerdctl";
19 rev = "v${version}";
20 hash = "sha256-GHFs8QvLcXu+DZ851TCLI7EVc9wMS5fRC4TYBXzyv3Q=";
21 };
22
23 vendorHash = "sha256-5LRsT04T/CKv+YHaiM2g6giimWWXyzPju3iZuj2DfAY=";
24
25 nativeBuildInputs = [
26 makeWrapper
27 installShellFiles
28 ];
29
30 ldflags =
31 let
32 t = "github.com/containerd/nerdctl/pkg/version";
33 in
34 [
35 "-s"
36 "-w"
37 "-X ${t}.Version=v${version}"
38 "-X ${t}.Revision=<unknown>"
39 ];
40
41 # Many checks require a containerd socket and running nerdctl after it's built
42 doCheck = false;
43
44 postInstall = ''
45 wrapProgram $out/bin/nerdctl \
46 --prefix PATH : "${lib.makeBinPath ([ buildkit ] ++ extraPackages)}" \
47 --prefix CNI_PATH : "${cni-plugins}/bin"
48
49 installShellCompletion --cmd nerdctl \
50 --bash <($out/bin/nerdctl completion bash) \
51 --fish <($out/bin/nerdctl completion fish) \
52 --zsh <($out/bin/nerdctl completion zsh)
53 '';
54
55 doInstallCheck = true;
56 installCheckPhase = ''
57 runHook preInstallCheck
58 $out/bin/nerdctl --help
59 $out/bin/nerdctl --version | grep "nerdctl version ${version}"
60 runHook postInstallCheck
61 '';
62
63 meta = {
64 homepage = "https://github.com/containerd/nerdctl/";
65 changelog = "https://github.com/containerd/nerdctl/releases/tag/v${version}";
66 description = "Docker-compatible CLI for containerd";
67 mainProgram = "nerdctl";
68 license = lib.licenses.asl20;
69 maintainers = with lib.maintainers; [
70 developer-guy
71 jk
72 ];
73 platforms = lib.platforms.linux;
74 };
75}