1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7}:
8let
9 version = "0.28.6";
10in
11buildGoModule {
12 pname = "step-cli";
13 inherit version;
14
15 src = fetchFromGitHub {
16 owner = "smallstep";
17 repo = "cli";
18 tag = "v${version}";
19 hash = "sha256-9tw/d6n6tzhBhBqizDG1dGhj8se9GF2DtrfYwwhvsLs=";
20 # this file change depending on git branch status (via .gitattributes)
21 # https://github.com/NixOS/nixpkgs/issues/84312
22 postFetch = ''
23 rm -f $out/.VERSION
24 '';
25 };
26
27 ldflags = [
28 "-w"
29 "-s"
30 "-X=main.Version=${version}"
31 ];
32
33 preCheck = ''
34 # Tries to connect to smallstep.com
35 rm command/certificate/remote_test.go
36 '';
37
38 vendorHash = "sha256-+pHc2uBgQwMkJ7BTgHGHDPgfBpLlN0Yxf+6Enhb7cys=";
39
40 nativeBuildInputs = [ installShellFiles ];
41
42 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
43 installShellCompletion --cmd step \
44 --bash <($out/bin/step completion bash) \
45 --zsh <($out/bin/step completion zsh) \
46 --fish <($out/bin/step completion fish)
47 '';
48
49 meta = {
50 description = "Zero trust swiss army knife for working with X509, OAuth, JWT, OATH OTP, etc";
51 homepage = "https://smallstep.com/cli/";
52 changelog = "https://github.com/smallstep/cli/blob/v${version}/CHANGELOG.md";
53 license = lib.licenses.asl20;
54 maintainers = with lib.maintainers; [ isabelroses ];
55 platforms = lib.platforms.linux ++ lib.platforms.darwin;
56 mainProgram = "step";
57 };
58}