1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 installShellFiles,
6 nix-update-script,
7 go,
8 testers,
9 pulsarctl,
10}:
11
12buildGoModule rec {
13 pname = "pulsarctl";
14 version = "4.0.4.3";
15
16 src = fetchFromGitHub {
17 owner = "streamnative";
18 repo = "pulsarctl";
19 rev = "v${version}";
20 hash = "sha256-acNd3nF1nHkYlw7tPoD01IjEc97dLvyAZ7yC1UDWN7s=";
21 };
22
23 vendorHash = "sha256-AruXsUIKeUMcojf0XF1ZEaZ2LlXDwCp2n82RN5e0Rj8=";
24
25 nativeBuildInputs = [ installShellFiles ];
26
27 ldflags =
28 let
29 buildVars = {
30 ReleaseVersion = version;
31 BuildTS = "None";
32 GitHash = src.rev;
33 GitBranch = "None";
34 GoVersion = "go${go.version}";
35 };
36 in
37 (lib.mapAttrsToList (
38 k: v: "-X github.com/streamnative/pulsarctl/pkg/cmdutils.${k}=${v}"
39 ) buildVars);
40
41 excludedPackages = [
42 "./pkg/test"
43 "./pkg/test/bookkeeper"
44 "./pkg/test/bookkeeper/containers"
45 "./pkg/test/pulsar"
46 "./pkg/test/pulsar/containers"
47 "./site/gen-pulsarctldocs"
48 "./site/gen-pulsarctldocs/generators"
49 ];
50
51 doCheck = false;
52
53 postInstall = ''
54 installShellCompletion --cmd pulsarctl \
55 --bash <($out/bin/pulsarctl completion bash) \
56 --fish <($out/bin/pulsarctl completion fish) \
57 --zsh <($out/bin/pulsarctl completion zsh)
58 '';
59
60 passthru = {
61 updateScript = nix-update-script { };
62 tests.version = testers.testVersion {
63 package = pulsarctl;
64 command = "pulsarctl --version";
65 version = "v${version}";
66 };
67 };
68
69 meta = with lib; {
70 description = "CLI for Apache Pulsar written in Go";
71 homepage = "https://github.com/streamnative/pulsarctl";
72 license = with licenses; [ asl20 ];
73 platforms = platforms.unix;
74 maintainers = with maintainers; [ gaelreyrol ];
75 mainProgram = "pulsarctl";
76 };
77}