summaryrefslogtreecommitdiffstats
path: root/pkgs/servers/monitoring/sensu-go/default.nix
blob: 8a8f1afb3b8edea06252b4ef09a832a2a3474a16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  buildGoModule,
  fetchFromGitHub,
  lib,
}:

let
  generic =
    {
      subPackages,
      pname,
      postInstall ? "",
      mainProgram,
    }:
    buildGoModule rec {
      inherit pname;
      version = "6.14.2";
      shortRev = "591ed6e"; # for internal version info

      src = fetchFromGitHub {
        owner = "sensu";
        repo = "sensu-go";
        rev = "v${version}";
        sha256 = "sha256-DlJneEAmkWqM5SgbUvvFmiSZzapQd+IpMivlB9r47W8=";
      };

      inherit subPackages postInstall;

      vendorHash = "sha256-iNIpUABozQpnBUiWBrp2ii4mNRKKJtChLiHnlaEQqvU=";

      doCheck = false;

      ldflags =
        let
          versionPkg = "github.com/sensu/sensu-go/version";
        in
        [
          "-X ${versionPkg}.Version=${version}"
          "-X ${versionPkg}.BuildSHA=${shortRev}"
        ];

      meta = {
        inherit mainProgram;
        homepage = "https://sensu.io";
        description = "Open source monitoring tool for ephemeral infrastructure & distributed applications";
        license = lib.licenses.mit;
        maintainers = with lib.maintainers; [
          thefloweringash
        ];
      };
    };
in
{
  sensu-go-cli = generic {
    pname = "sensu-go-cli";
    subPackages = [ "cmd/sensuctl" ];
    postInstall = ''
      mkdir -p \
        "''${!outputBin}/share/bash-completion/completions" \
        "''${!outputBin}/share/zsh/site-functions"

      ''${!outputBin}/bin/sensuctl completion bash > ''${!outputBin}/share/bash-completion/completions/sensuctl

      # https://github.com/sensu/sensu-go/issues/3132
      (
        echo "#compdef sensuctl"
        ''${!outputBin}/bin/sensuctl completion zsh
        echo '_complete sensuctl 2>/dev/null'
      ) > ''${!outputBin}/share/zsh/site-functions/_sensuctl

    '';
    mainProgram = "sensuctl";
  };

  sensu-go-backend = generic {
    pname = "sensu-go-backend";
    subPackages = [ "cmd/sensu-backend" ];
    mainProgram = "sensu-backend";
  };

  sensu-go-agent = generic {
    pname = "sensu-go-agent";
    subPackages = [ "cmd/sensu-agent" ];
    mainProgram = "sensu-agent";
  };
}