summary refs log tree commit diff
path: root/pkgs/servers/monitoring/prometheus/pushgateway.nix
blob: 0a707519c64eec6e45c7fa6f24121960c4e06de7 (plain) (blame)
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
{ stdenv, go, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  pname = "pushgateway";
  version = "1.2.0";
  rev = "v${version}";

  goPackagePath = "github.com/prometheus/pushgateway";

  src = fetchFromGitHub {
    inherit rev;
    owner = "prometheus";
    repo = "pushgateway";
    sha256 = "0q57pvdfapi1xx8mw7ykvxs64alypyqbxwvrqjcrgv2jidbcd1mm";
  };

  buildUser = "nix@nixpkgs";
  buildDate = "19700101-00:00:00";

  buildFlagsArray = ''
    -ldflags=
        -X github.com/prometheus/pushgateway/vendor/github.com/prometheus/common/version.Version=${version}
        -X github.com/prometheus/pushgateway/vendor/github.com/prometheus/common/version.Revision=${rev}
        -X github.com/prometheus/pushgateway/vendor/github.com/prometheus/common/version.Branch=${rev}
        -X github.com/prometheus/pushgateway/vendor/github.com/prometheus/common/version.BuildUser=${buildUser}
        -X github.com/prometheus/pushgateway/vendor/github.com/prometheus/common/version.BuildDate=${buildDate}
        -X main.goVersion=${stdenv.lib.getVersion go}
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    export PATH=$PATH:$bin/bin

    pushgateway --help

    # Make sure our -X options were included in the build
    for s in ${version} ${rev} ${buildUser} ${buildDate}; do
      pushgateway --version 2>&1 | fgrep -q -- "$s" || { echo "pushgateway --version output missing $s"; exit 1; }
    done
  '';

  meta = with stdenv.lib; {
    description = "Allows ephemeral and batch jobs to expose metrics to Prometheus";
    homepage = https://github.com/prometheus/pushgateway;
    license = licenses.asl20;
    maintainers = with maintainers; [ benley fpletz ];
    platforms = platforms.unix;
  };
}