1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 nixosTests,
6}:
7
8buildGoModule rec {
9 pname = "postgres_exporter";
10 version = "0.17.1";
11
12 src = fetchFromGitHub {
13 owner = "prometheus-community";
14 repo = "postgres_exporter";
15 rev = "v${version}";
16 sha256 = "sha256-F7nLz6NkvWSeZTzjo1/wNWCPn3Veo9/SkJdlFRwdlo4=";
17 };
18
19 vendorHash = "sha256-Dl44VTaDE90nhOU0zxZvd/zrVe8bLRnT16ISqJMpzpU=";
20
21 ldflags =
22 let
23 t = "github.com/prometheus/common/version";
24 in
25 [
26 "-s"
27 "-w"
28 "-X ${t}.Version=${version}"
29 "-X ${t}.Revision=unknown"
30 "-X ${t}.Branch=unknown"
31 "-X ${t}.BuildUser=nix@nixpkgs"
32 "-X ${t}.BuildDate=unknown"
33 ];
34
35 doCheck = true;
36
37 passthru.tests = { inherit (nixosTests.prometheus-exporters) postgres; };
38
39 meta = with lib; {
40 inherit (src.meta) homepage;
41 description = "Prometheus exporter for PostgreSQL";
42 mainProgram = "postgres_exporter";
43 license = licenses.asl20;
44 maintainers = with maintainers; [
45 fpletz
46 globin
47 ma27
48 ];
49 };
50}