2021-07-24 12:14:16 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, go
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
2022-04-27 09:35:20 +00:00
|
|
|
, fetchurl
|
2021-07-24 12:14:16 +00:00
|
|
|
, nixosTests
|
2022-02-20 05:27:41 +00:00
|
|
|
, enableAWS ? true
|
|
|
|
, enableAzure ? true
|
|
|
|
, enableConsul ? true
|
|
|
|
, enableDigitalOcean ? true
|
2022-07-14 12:49:19 +00:00
|
|
|
, enableDNS ? true
|
2022-02-20 05:27:41 +00:00
|
|
|
, enableEureka ? true
|
|
|
|
, enableGCE ? true
|
|
|
|
, enableHetzner ? true
|
2022-06-26 10:26:21 +00:00
|
|
|
, enableIONOS ? true
|
2022-02-20 05:27:41 +00:00
|
|
|
, enableKubernetes ? true
|
|
|
|
, enableLinode ? true
|
|
|
|
, enableMarathon ? true
|
|
|
|
, enableMoby ? true
|
2022-09-09 14:08:57 +00:00
|
|
|
, enableNomad ? true
|
2022-02-20 05:27:41 +00:00
|
|
|
, enableOpenstack ? true
|
2023-03-15 16:39:30 +00:00
|
|
|
, enableOVHCloud ? true
|
2022-02-20 05:27:41 +00:00
|
|
|
, enablePuppetDB ? true
|
|
|
|
, enableScaleway ? true
|
|
|
|
, enableTriton ? true
|
|
|
|
, enableUyuni ? true
|
2022-06-26 10:26:21 +00:00
|
|
|
, enableVultr ? true
|
2022-02-20 05:27:41 +00:00
|
|
|
, enableXDS ? true
|
|
|
|
, enableZookeeper ? true
|
2020-12-25 13:55:36 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "2.47.1";
|
2022-04-27 09:35:20 +00:00
|
|
|
webUiStatic = fetchurl {
|
|
|
|
url = "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-web-ui-${version}.tar.gz";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-NgVwxKhag/acE5sdP3910CuGWVWfmTSnXSSztEjLobs=";
|
2022-04-27 09:35:20 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "prometheus";
|
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
outputs = [ "out" "doc" "cli" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "prometheus";
|
|
|
|
repo = "prometheus";
|
2023-03-15 16:39:30 +00:00
|
|
|
rev = "v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-AK2DLFDWrpnkvOUb9dFYjdAa6+Vm6ftZQpexy/FULrs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
vendorHash = "sha256-qFp+tMHhXmJGY9MSukVRjBVzaIBgfxB0BorWiuInMwk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
excludedPackages = [ "documentation/prometheus-mixin" ];
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
2022-04-27 09:35:20 +00:00
|
|
|
tar -C web/ui -xzf ${webUiStatic}
|
|
|
|
|
|
|
|
patchShebangs scripts
|
|
|
|
|
|
|
|
# Enable only select service discovery to shrink binaries.
|
|
|
|
(
|
2023-03-15 16:39:30 +00:00
|
|
|
true # prevent bash syntax error when all plugins are disabled
|
|
|
|
${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"}
|
|
|
|
${lib.optionalString enableDNS "echo - github.com/prometheus/prometheus/discovery/dns"}
|
|
|
|
${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"}
|
|
|
|
${lib.optionalString enableIONOS "echo - github.com/prometheus/prometheus/discovery/ionos"}
|
|
|
|
${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"}
|
|
|
|
${lib.optionalString enableNomad "echo - github.com/prometheus/prometheus/discovery/nomad"}
|
|
|
|
${lib.optionalString enableOpenstack "echo - github.com/prometheus/prometheus/discovery/openstack"}
|
|
|
|
${lib.optionalString enableOVHCloud "echo - github.com/prometheus/prometheus/discovery/ovhcloud"}
|
|
|
|
${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"}
|
|
|
|
${lib.optionalString enableVultr "echo - github.com/prometheus/prometheus/discovery/vultr"}
|
|
|
|
${lib.optionalString enableXDS "echo - github.com/prometheus/prometheus/discovery/xds"}
|
|
|
|
${lib.optionalString enableZookeeper "echo - github.com/prometheus/prometheus/discovery/zookeeper"}
|
2022-04-27 09:35:20 +00:00
|
|
|
) > plugins.yml
|
|
|
|
'';
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
preBuild = ''
|
2022-09-09 14:08:57 +00:00
|
|
|
if [[ -d vendor ]]; then GOARCH= make -o assets assets-compress plugins; fi
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-08 23:34:03 +00:00
|
|
|
tags = [ "builtinassets" ];
|
|
|
|
|
|
|
|
ldflags =
|
2021-07-24 12:14:16 +00:00
|
|
|
let
|
2022-04-27 09:35:20 +00:00
|
|
|
t = "github.com/prometheus/common/version";
|
2021-07-24 12:14:16 +00:00
|
|
|
in
|
|
|
|
[
|
2023-03-15 16:39:30 +00:00
|
|
|
"-s"
|
|
|
|
"-w"
|
2021-08-08 23:34:03 +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-24 12:14:16 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preInstall = ''
|
2020-05-15 21:57:56 +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
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
postInstall = ''
|
|
|
|
moveToOutput bin/promtool $cli
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# https://hydra.nixos.org/build/130673870/nixlog/1
|
|
|
|
# Test mock data uses 64 bit data without an explicit (u)int64
|
|
|
|
doCheck = !(stdenv.isDarwin || stdenv.hostPlatform.parsed.cpu.bits < 64);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
passthru.tests = { inherit (nixosTests) prometheus; };
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Service monitoring system and time series database";
|
|
|
|
homepage = "https://prometheus.io";
|
|
|
|
license = licenses.asl20;
|
2023-03-15 16:39:30 +00:00
|
|
|
maintainers = with maintainers; [ fpletz willibutz Frostman ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|