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