2021-07-22 06:01:13 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, go
|
2021-10-13 18:26:26 +00:00
|
|
|
, pkgs
|
2021-07-22 06:01:13 +00:00
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
2022-04-14 20:36:38 +00:00
|
|
|
, fetchurl
|
2021-07-22 06:01:13 +00:00
|
|
|
, nixosTests
|
2022-01-28 23:40:46 +00:00
|
|
|
, enableAWS ? true
|
|
|
|
, enableAzure ? true
|
2022-02-06 23:16:27 +00:00
|
|
|
, enableConsul ? true
|
2022-01-28 23:40:46 +00:00
|
|
|
, enableDigitalOcean ? true
|
2022-06-03 11:59:26 +00:00
|
|
|
, enableDNS ? true
|
2022-02-06 23:16:27 +00:00
|
|
|
, enableEureka ? true
|
2022-01-28 23:40:46 +00:00
|
|
|
, enableGCE ? true
|
2022-02-06 23:16:27 +00:00
|
|
|
, enableHetzner ? true
|
2022-06-08 13:24:33 +00:00
|
|
|
, enableIONOS ? true
|
2022-01-28 23:40:46 +00:00
|
|
|
, enableKubernetes ? true
|
|
|
|
, enableLinode ? true
|
2022-02-06 23:16:27 +00:00
|
|
|
, enableMarathon ? true
|
|
|
|
, enableMoby ? true
|
2022-08-23 11:14:49 +00:00
|
|
|
, enableNomad ? true
|
2022-02-06 23:16:27 +00:00
|
|
|
, enableOpenstack ? true
|
|
|
|
, enablePuppetDB ? true
|
|
|
|
, enableScaleway ? true
|
|
|
|
, enableTriton ? true
|
|
|
|
, enableUyuni ? true
|
2022-06-08 13:24:33 +00:00
|
|
|
, enableVultr ? true
|
2022-02-06 23:16:27 +00:00
|
|
|
, enableXDS ? true
|
|
|
|
, enableZookeeper ? true
|
2020-12-23 12:09:41 +00:00
|
|
|
}:
|
2016-06-05 11:34:18 +00:00
|
|
|
|
2019-12-04 14:42:07 +00:00
|
|
|
let
|
2023-01-19 12:02:02 +00:00
|
|
|
version = "2.41.0";
|
2022-04-14 20:36:38 +00:00
|
|
|
webUiStatic = fetchurl {
|
|
|
|
url = "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-web-ui-${version}.tar.gz";
|
2023-01-19 12:02:02 +00:00
|
|
|
sha256 = "sha256-0EFeAuhQUu+4TCoHsWHTbWTGJLjS37POacP1K42sGqI=";
|
2022-04-14 20:36:38 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "prometheus";
|
|
|
|
inherit version;
|
2018-03-11 00:08:34 +00:00
|
|
|
|
2019-09-06 19:33:32 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
rev = "v${version}";
|
|
|
|
owner = "prometheus";
|
|
|
|
repo = "prometheus";
|
2023-01-19 12:02:02 +00:00
|
|
|
sha256 = "sha256-J3KDN02m639bUGrnUrqeCLferrqIHaJ2VEBjIqfm/GY=";
|
2019-12-04 14:42:07 +00:00
|
|
|
};
|
|
|
|
|
2023-01-19 12:02:02 +00:00
|
|
|
vendorSha256 = "sha256-4Of1euBp5Lka6Bb2UJYUQuRa7t2/B1HaXCWSOqCASYw=";
|
2019-12-04 14:42:07 +00:00
|
|
|
|
2021-05-11 03:22:39 +00:00
|
|
|
excludedPackages = [ "documentation/prometheus-mixin" ];
|
2020-12-23 12:09:41 +00:00
|
|
|
|
2019-12-04 14:42:07 +00:00
|
|
|
postPatch = ''
|
2022-04-14 20:36:38 +00:00
|
|
|
tar -C web/ui -xzf ${webUiStatic}
|
|
|
|
|
|
|
|
patchShebangs scripts
|
|
|
|
|
|
|
|
# Enable only select service discovery to shrink binaries.
|
|
|
|
(
|
2022-05-13 13:59:12 +00:00
|
|
|
true # prevent bash syntax error when all plugins are disabled
|
2022-04-14 20:36:38 +00:00
|
|
|
${lib.optionalString (enableAWS)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/aws"}
|
|
|
|
${lib.optionalString (enableAzure)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/azure"}
|
|
|
|
${lib.optionalString (enableConsul)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/consul"}
|
|
|
|
${lib.optionalString (enableDigitalOcean)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/digitalocean"}
|
2022-06-03 11:59:26 +00:00
|
|
|
${lib.optionalString (enableDNS)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/dns"}
|
2022-04-14 20:36:38 +00:00
|
|
|
${lib.optionalString (enableEureka)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/eureka"}
|
|
|
|
${lib.optionalString (enableGCE)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/gce"}
|
|
|
|
${lib.optionalString (enableHetzner)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/hetzner"}
|
2022-06-08 13:24:33 +00:00
|
|
|
${lib.optionalString (enableIONOS)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/ionos"}
|
2022-04-14 20:36:38 +00:00
|
|
|
${lib.optionalString (enableKubernetes)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/kubernetes"}
|
|
|
|
${lib.optionalString (enableLinode)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/linode"}
|
|
|
|
${lib.optionalString (enableMarathon)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/marathon"}
|
|
|
|
${lib.optionalString (enableMoby)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/moby"}
|
2022-08-23 11:14:49 +00:00
|
|
|
${lib.optionalString (enableNomad)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/nomad"}
|
2022-04-14 20:36:38 +00:00
|
|
|
${lib.optionalString (enableOpenstack)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/openstack"}
|
|
|
|
${lib.optionalString (enablePuppetDB)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/puppetdb"}
|
|
|
|
${lib.optionalString (enableScaleway)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/scaleway"}
|
|
|
|
${lib.optionalString (enableTriton)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/triton"}
|
|
|
|
${lib.optionalString (enableUyuni)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/uyuni"}
|
2022-06-08 13:24:33 +00:00
|
|
|
${lib.optionalString (enableVultr)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/vultr"}
|
2022-04-14 20:36:38 +00:00
|
|
|
${lib.optionalString (enableXDS)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/xds"}
|
|
|
|
${lib.optionalString (enableZookeeper)
|
|
|
|
"echo - github.com/prometheus/prometheus/discovery/zookeeper"}
|
|
|
|
) > plugins.yml
|
|
|
|
'';
|
2022-01-28 23:40:46 +00:00
|
|
|
|
2022-04-14 20:36:38 +00:00
|
|
|
preBuild = ''
|
2022-08-24 19:35:13 +00:00
|
|
|
if [[ -d vendor ]]; then GOARCH= make -o assets assets-compress plugins; fi
|
2019-12-04 14:42:07 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-08 00:11:16 +00:00
|
|
|
tags = [ "builtinassets" ];
|
|
|
|
|
|
|
|
ldflags =
|
2021-07-22 06:01:13 +00:00
|
|
|
let
|
2022-04-14 20:36:38 +00:00
|
|
|
t = "github.com/prometheus/common/version";
|
2021-07-22 06:01:13 +00:00
|
|
|
in
|
|
|
|
[
|
2021-08-08 00:11:16 +00:00
|
|
|
"-X ${t}.Version=${version}"
|
|
|
|
"-X ${t}.Revision=unknown"
|
|
|
|
"-X ${t}.Branch=unknown"
|
|
|
|
"-X ${t}.BuildUser=nix@nixpkgs"
|
|
|
|
"-X ${t}.BuildDate=unknown"
|
|
|
|
"-X ${t}.GoVersion=${lib.getVersion go}"
|
2021-07-22 06:01:13 +00:00
|
|
|
];
|
2019-12-04 14:42:07 +00:00
|
|
|
|
2019-09-06 19:33:32 +00:00
|
|
|
preInstall = ''
|
2020-04-28 01:50:57 +00:00
|
|
|
mkdir -p "$out/share/doc/prometheus" "$out/etc/prometheus"
|
|
|
|
cp -a $src/documentation/* $out/share/doc/prometheus
|
|
|
|
cp -a $src/console_libraries $src/consoles $out/etc/prometheus
|
2019-09-06 19:33:32 +00:00
|
|
|
'';
|
|
|
|
|
2022-04-14 20:36:38 +00:00
|
|
|
doCheck = !stdenv.isDarwin; # https://hydra.nixos.org/build/130673870/nixlog/1
|
2019-09-06 19:33:32 +00:00
|
|
|
|
2020-08-20 09:14:02 +00:00
|
|
|
passthru.tests = { inherit (nixosTests) prometheus; };
|
|
|
|
|
2019-09-06 19:33:32 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Service monitoring system and time series database";
|
|
|
|
homepage = "https://prometheus.io";
|
|
|
|
license = licenses.asl20;
|
2020-02-14 19:45:21 +00:00
|
|
|
maintainers = with maintainers; [ benley fpletz globin willibutz Frostman ];
|
2019-09-06 19:33:32 +00:00
|
|
|
platforms = platforms.unix;
|
2016-06-05 11:34:18 +00:00
|
|
|
};
|
|
|
|
}
|