nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7}:
8
9buildGoModule rec {
10 pname = "nsc";
11 version = "2.11.0";
12
13 src = fetchFromGitHub {
14 owner = "nats-io";
15 repo = "nsc";
16 rev = "v${version}";
17 hash = "sha256-/xfNl91cb82kV2IC/m56p94nb3WLDPU5O+1H+sTZnW4=";
18 };
19
20 ldflags = [
21 "-s"
22 "-w"
23 "-X main.version=v${version}"
24 "-X main.builtBy=nixpkgs"
25 ];
26
27 vendorHash = "sha256-Ms+chBbQCo3TGWPgIy4OSXNpxO5jpm1zxEe9upiPmnY=";
28
29 nativeBuildInputs = [ installShellFiles ];
30
31 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
32 installShellCompletion --cmd nsc \
33 --bash <($out/bin/nsc completion bash) \
34 --fish <($out/bin/nsc completion fish) \
35 --zsh <($out/bin/nsc completion zsh)
36 '';
37
38 preInstall = ''
39 # asc attempt to write to the home directory.
40 export HOME=$(mktemp -d)
41 '';
42
43 preCheck = preInstall;
44
45 # Tests currently fail on darwin because of a test in nsc which
46 # expects command output to contain a specific path. However
47 # the test strips table formatting from the command output in a naive way
48 # that removes all the table characters, including '-'.
49 # The nix build directory looks something like:
50 # /private/tmp/nix-build-nsc-2.11.0.drv-0/nsc_test2000598938/keys
51 # Then the `-` are removed from the path unintentionally and the test fails.
52 # This should be fixed upstream to avoid mangling the path when
53 # removing the table decorations from the command output.
54 doCheck = !stdenv.hostPlatform.isDarwin;
55
56 meta = {
57 description = "Tool for creating NATS account and user access configurations";
58 homepage = "https://github.com/nats-io/nsc";
59 license = with lib.licenses; [ asl20 ];
60 maintainers = with lib.maintainers; [ cbrewster ];
61 mainProgram = "nsc";
62 };
63}