kubedog: 0.12.3 -> 0.13.0 (#375971)
[NixPkgs.git] / pkgs / by-name / pr / prometheus / package.nix
bloba183cb6573b88c422be92a9c6bbb3f60ea37460c
2   stdenv,
3   lib,
4   go,
5   buildGoModule,
6   fetchFromGitHub,
7   fetchurl,
8   nixosTests,
9   enableAWS ? true,
10   enableAzure ? true,
11   enableConsul ? true,
12   enableDigitalOcean ? true,
13   enableDNS ? true,
14   enableEureka ? true,
15   enableGCE ? true,
16   enableHetzner ? true,
17   enableIONOS ? true,
18   enableKubernetes ? true,
19   enableLinode ? true,
20   enableMarathon ? true,
21   enableMoby ? true,
22   enableNomad ? true,
23   enableOpenstack ? true,
24   enableOVHCloud ? true,
25   enablePuppetDB ? true,
26   enableScaleway ? true,
27   enableTriton ? true,
28   enableUyuni ? true,
29   enableVultr ? true,
30   enableXDS ? true,
31   enableZookeeper ? true,
34 let
35   version = "3.0.1";
36   webUiStatic = fetchurl {
37     url = "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-web-ui-${version}.tar.gz";
38     hash = "sha256-MP7B7gVRQnspXLLNmPH8t3DYKbsQkDV9hPJYbM2rB9M=";
39   };
41 buildGoModule rec {
42   pname = "prometheus";
43   inherit version;
45   outputs = [
46     "out"
47     "doc"
48     "cli"
49   ];
51   src = fetchFromGitHub {
52     owner = "prometheus";
53     repo = "prometheus";
54     rev = "v${version}";
55     hash = "sha256-dN6ckW451G45ZO7baY7H4qEf88ZDeISZwZ3uwWPZsW8=";
56   };
58   vendorHash = "sha256-c96YnWPLH/tbGRb2Zlqrl3PXSZvI+NeYTGlef6REAOw=";
60   excludedPackages = [
61     "documentation/prometheus-mixin"
62     "web/ui/mantine-ui/src/promql/tools"
63   ];
65   postPatch = ''
66     tar -C web/ui -xzf ${webUiStatic}
68     patchShebangs scripts
70     # Enable only select service discovery to shrink binaries.
71     (
72       true # prevent bash syntax error when all plugins are disabled
73     ${lib.optionalString enableAWS "echo - github.com/prometheus/prometheus/discovery/aws"}
74     ${lib.optionalString enableAzure "echo - github.com/prometheus/prometheus/discovery/azure"}
75     ${lib.optionalString enableConsul "echo - github.com/prometheus/prometheus/discovery/consul"}
76     ${lib.optionalString enableDigitalOcean "echo - github.com/prometheus/prometheus/discovery/digitalocean"}
77     ${lib.optionalString enableDNS "echo - github.com/prometheus/prometheus/discovery/dns"}
78     ${lib.optionalString enableEureka "echo - github.com/prometheus/prometheus/discovery/eureka"}
79     ${lib.optionalString enableGCE "echo - github.com/prometheus/prometheus/discovery/gce"}
80     ${lib.optionalString enableHetzner "echo - github.com/prometheus/prometheus/discovery/hetzner"}
81     ${lib.optionalString enableIONOS "echo - github.com/prometheus/prometheus/discovery/ionos"}
82     ${lib.optionalString enableKubernetes "echo - github.com/prometheus/prometheus/discovery/kubernetes"}
83     ${lib.optionalString enableLinode "echo - github.com/prometheus/prometheus/discovery/linode"}
84     ${lib.optionalString enableMarathon "echo - github.com/prometheus/prometheus/discovery/marathon"}
85     ${lib.optionalString enableMoby "echo - github.com/prometheus/prometheus/discovery/moby"}
86     ${lib.optionalString enableNomad "echo - github.com/prometheus/prometheus/discovery/nomad"}
87     ${lib.optionalString enableOpenstack "echo - github.com/prometheus/prometheus/discovery/openstack"}
88     ${lib.optionalString enableOVHCloud "echo - github.com/prometheus/prometheus/discovery/ovhcloud"}
89     ${lib.optionalString enablePuppetDB "echo - github.com/prometheus/prometheus/discovery/puppetdb"}
90     ${lib.optionalString enableScaleway "echo - github.com/prometheus/prometheus/discovery/scaleway"}
91     ${lib.optionalString enableTriton "echo - github.com/prometheus/prometheus/discovery/triton"}
92     ${lib.optionalString enableUyuni "echo - github.com/prometheus/prometheus/discovery/uyuni"}
93     ${lib.optionalString enableVultr "echo - github.com/prometheus/prometheus/discovery/vultr"}
94     ${lib.optionalString enableXDS "echo - github.com/prometheus/prometheus/discovery/xds"}
95     ${lib.optionalString enableZookeeper "echo - github.com/prometheus/prometheus/discovery/zookeeper"}
96     ) > plugins.yml
97   '';
99   preBuild = ''
100     if [[ -d vendor ]]; then GOARCH= make -o assets assets-compress plugins; fi
101   '';
103   tags = [ "builtinassets" ];
105   ldflags =
106     let
107       t = "github.com/prometheus/common/version";
108     in
109     [
110       "-s"
111       "-w"
112       "-X ${t}.Version=${version}"
113       "-X ${t}.Revision=unknown"
114       "-X ${t}.Branch=unknown"
115       "-X ${t}.BuildUser=nix@nixpkgs"
116       "-X ${t}.BuildDate=unknown"
117       "-X ${t}.GoVersion=${lib.getVersion go}"
118     ];
120   preInstall = ''
121     mkdir -p "$out/share/doc/prometheus" "$out/etc/prometheus"
122     cp -a $src/documentation/* $out/share/doc/prometheus
123   '';
125   postInstall = ''
126     moveToOutput bin/promtool $cli
127   '';
129   # https://hydra.nixos.org/build/130673870/nixlog/1
130   # Test mock data uses 64 bit data without an explicit (u)int64
131   doCheck = !(stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.parsed.cpu.bits < 64);
133   passthru.tests = { inherit (nixosTests) prometheus; };
135   meta = with lib; {
136     description = "Service monitoring system and time series database";
137     homepage = "https://prometheus.io";
138     license = licenses.asl20;
139     maintainers = with maintainers; [
140       fpletz
141       willibutz
142       Frostman
143     ];
144   };