2021-07-22 08:01:13 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, go
|
2021-10-13 20:26:26 +02:00
|
|
|
, pkgs
|
2021-12-26 12:03:07 +01:00
|
|
|
, nodejs-14_x
|
2021-10-13 20:26:26 +02:00
|
|
|
, nodePackages
|
2021-07-22 08:01:13 +02:00
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, mkYarnPackage
|
|
|
|
, nixosTests
|
2020-12-23 13:09:41 +01:00
|
|
|
, fetchpatch
|
2022-01-29 00:40:46 +01:00
|
|
|
, enableAWS ? true
|
|
|
|
, enableAzure ? true
|
2022-02-07 00:16:27 +01:00
|
|
|
, enableConsul ? true
|
2022-01-29 00:40:46 +01:00
|
|
|
, enableDigitalOcean ? true
|
2022-02-07 00:16:27 +01:00
|
|
|
, enableEureka ? true
|
2022-01-29 00:40:46 +01:00
|
|
|
, enableGCE ? true
|
2022-02-07 00:16:27 +01:00
|
|
|
, enableHetzner ? true
|
2022-01-29 00:40:46 +01:00
|
|
|
, enableKubernetes ? true
|
|
|
|
, enableLinode ? true
|
2022-02-07 00:16:27 +01:00
|
|
|
, enableMarathon ? true
|
|
|
|
, enableMoby ? true
|
|
|
|
, enableOpenstack ? true
|
|
|
|
, enablePuppetDB ? true
|
|
|
|
, enableScaleway ? true
|
|
|
|
, enableTriton ? true
|
|
|
|
, enableUyuni ? true
|
|
|
|
, enableXDS ? true
|
|
|
|
, enableZookeeper ? true
|
2020-12-23 13:09:41 +01:00
|
|
|
}:
|
2016-06-05 13:34:18 +02:00
|
|
|
|
2019-12-04 15:42:07 +01:00
|
|
|
let
|
2021-10-13 20:26:26 +02:00
|
|
|
version = "2.30.3";
|
2018-03-11 01:08:34 +01:00
|
|
|
|
2019-09-06 21:33:32 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
rev = "v${version}";
|
|
|
|
owner = "prometheus";
|
|
|
|
repo = "prometheus";
|
2021-10-13 20:26:26 +02:00
|
|
|
sha256 = "1as6x5bsp7mxa4rp7jhyjlpcvzqm1zngnwvp73rc4rwhz8w8vm3k";
|
2016-06-05 13:34:18 +02:00
|
|
|
};
|
|
|
|
|
2021-05-11 05:22:39 +02:00
|
|
|
goPackagePath = "github.com/prometheus/prometheus";
|
|
|
|
|
2021-10-13 20:26:26 +02:00
|
|
|
codemirrorNode = import ./webui/codemirror-promql {
|
2021-12-26 12:03:07 +01:00
|
|
|
inherit pkgs;
|
|
|
|
nodejs = nodejs-14_x;
|
2021-10-13 20:26:26 +02:00
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
};
|
|
|
|
webuiNode = import ./webui/webui {
|
2021-12-26 12:03:07 +01:00
|
|
|
inherit pkgs;
|
|
|
|
nodejs = nodejs-14_x;
|
2021-10-13 20:26:26 +02:00
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
};
|
|
|
|
|
|
|
|
codemirror = stdenv.mkDerivation {
|
|
|
|
name = "prometheus-webui-codemirror-promql";
|
|
|
|
src = "${src}/web/ui/module/codemirror-promql";
|
|
|
|
|
2021-12-26 12:03:07 +01:00
|
|
|
buildInputs = [ nodejs-14_x nodePackages.typescript codemirrorNode.nodeDependencies ];
|
2021-10-13 20:26:26 +02:00
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
ln -s ${codemirrorNode.nodeDependencies}/lib/node_modules node_modules
|
|
|
|
'';
|
|
|
|
buildPhase = ''
|
|
|
|
PUBLIC_URL=. npm run build
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
mv lib dist $out
|
|
|
|
'';
|
|
|
|
distPhase = ":";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
webui = stdenv.mkDerivation {
|
|
|
|
name = "prometheus-webui";
|
2019-12-04 15:42:07 +01:00
|
|
|
src = "${src}/web/ui/react-app";
|
2021-10-13 20:26:26 +02:00
|
|
|
|
2021-12-26 12:03:07 +01:00
|
|
|
buildInputs = [ nodejs-14_x webuiNode.nodeDependencies ];
|
2021-10-13 20:26:26 +02:00
|
|
|
|
|
|
|
# create `node_modules/.cache` dir (we need writeable .cache)
|
|
|
|
# and then copy the rest over.
|
|
|
|
configurePhase = ''
|
|
|
|
mkdir -p node_modules/{.cache,.bin}
|
|
|
|
cp -a ${webuiNode.nodeDependencies}/lib/node_modules/. node_modules
|
|
|
|
'';
|
|
|
|
buildPhase = "PUBLIC_URL=. npm run build";
|
2019-12-04 15:42:07 +01:00
|
|
|
installPhase = "mv build $out";
|
|
|
|
distPhase = "true";
|
|
|
|
};
|
2021-07-22 08:01:13 +02:00
|
|
|
in
|
|
|
|
buildGoModule rec {
|
2019-12-04 15:42:07 +01:00
|
|
|
pname = "prometheus";
|
|
|
|
inherit src version;
|
|
|
|
|
2021-10-13 20:26:26 +02:00
|
|
|
vendorSha256 = "0qyv8vybx5wg8k8hwvrpp4hz9wv6g4kf9sq5v5qc2bxx6apc0s9r";
|
2019-12-04 15:42:07 +01:00
|
|
|
|
2021-05-11 05:22:39 +02:00
|
|
|
excludedPackages = [ "documentation/prometheus-mixin" ];
|
2020-12-23 13:09:41 +01:00
|
|
|
|
2021-12-26 12:03:07 +01:00
|
|
|
nativeBuildInputs = [ nodejs-14_x ];
|
2021-10-13 20:26:26 +02:00
|
|
|
|
2019-12-04 15:42:07 +01:00
|
|
|
postPatch = ''
|
2021-10-13 20:26:26 +02:00
|
|
|
# we don't want this anyways, as we
|
|
|
|
# build modules for them
|
|
|
|
echo "exit 0" > web/ui/module/build.sh
|
|
|
|
|
|
|
|
ln -s ${webuiNode.nodeDependencies}/lib/node_modules web/ui/react-app/node_modules
|
2019-12-04 15:42:07 +01:00
|
|
|
ln -s ${webui} web/ui/static/react
|
2021-10-13 20:26:26 +02:00
|
|
|
|
|
|
|
# webui-codemirror
|
|
|
|
ln -s ${codemirror}/dist web/ui/module/codemirror-promql/dist
|
|
|
|
ln -s ${codemirror}/lib web/ui/module/codemirror-promql/lib
|
2022-01-29 00:40:46 +01:00
|
|
|
|
|
|
|
# Disable some service discovery to shrink binaries.
|
|
|
|
${lib.optionalString (!enableAWS)
|
|
|
|
"sed -i -e '/register aws/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableAzure)
|
|
|
|
"sed -i -e '/register azure/d' discovery/install/install.go"}
|
2022-02-07 00:16:27 +01:00
|
|
|
${lib.optionalString (!enableConsul)
|
|
|
|
"sed -i -e '/register consul/d' discovery/install/install.go"}
|
2022-01-29 00:40:46 +01:00
|
|
|
${lib.optionalString (!enableDigitalOcean)
|
|
|
|
"sed -i -e '/register digitalocean/d' discovery/install/install.go"}
|
2022-02-07 00:16:27 +01:00
|
|
|
${lib.optionalString (!enableEureka)
|
|
|
|
"sed -i -e '/register eureka/d' discovery/install/install.go"}
|
2022-01-29 00:40:46 +01:00
|
|
|
${lib.optionalString (!enableGCE)
|
|
|
|
"sed -i -e '/register gce/d' discovery/install/install.go"}
|
2022-02-07 00:16:27 +01:00
|
|
|
${lib.optionalString (!enableHetzner)
|
|
|
|
"sed -i -e '/register hetzner/d' discovery/install/install.go"}
|
2022-01-29 00:40:46 +01:00
|
|
|
${lib.optionalString (!enableKubernetes)
|
|
|
|
"sed -i -e '/register kubernetes/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableLinode)
|
|
|
|
"sed -i -e '/register linode/d' discovery/install/install.go"}
|
2022-02-07 00:16:27 +01:00
|
|
|
${lib.optionalString (!enableMarathon)
|
|
|
|
"sed -i -e '/register marathon/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableMoby)
|
|
|
|
"sed -i -e '/register moby/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableOpenstack)
|
|
|
|
"sed -i -e '/register openstack/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enablePuppetDB)
|
|
|
|
"sed -i -e '/register puppetdb/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableScaleway)
|
|
|
|
"sed -i -e '/register scaleway/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableTriton)
|
|
|
|
"sed -i -e '/register triton/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableUyuni)
|
|
|
|
"sed -i -e '/register uyuni/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableXDS)
|
|
|
|
"sed -i -e '/register xds/d' discovery/install/install.go"}
|
|
|
|
${lib.optionalString (!enableZookeeper)
|
|
|
|
"sed -i -e '/register zookeeper/d' discovery/install/install.go"}
|
2019-12-04 15:42:07 +01:00
|
|
|
'';
|
|
|
|
|
2021-08-08 02:11:16 +02:00
|
|
|
tags = [ "builtinassets" ];
|
|
|
|
|
|
|
|
ldflags =
|
2021-07-22 08:01:13 +02:00
|
|
|
let
|
|
|
|
t = "${goPackagePath}/vendor/github.com/prometheus/common/version";
|
|
|
|
in
|
|
|
|
[
|
2021-08-08 02:11:16 +02: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 08:01:13 +02:00
|
|
|
];
|
2019-12-04 15:42:07 +01:00
|
|
|
|
2021-05-11 05:22:39 +02:00
|
|
|
# only run this in the real build, not during the vendor build
|
|
|
|
# this should probably be fixed in buildGoModule
|
2019-12-04 15:42:07 +01:00
|
|
|
preBuild = ''
|
2021-05-11 05:22:39 +02:00
|
|
|
if [ -d vendor ]; then make assets; fi
|
2019-09-06 21:33:32 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
preInstall = ''
|
2020-04-28 03:50:57 +02: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 21:33:32 +02:00
|
|
|
'';
|
|
|
|
|
2021-07-22 08:01:46 +02:00
|
|
|
# doCheck = !stdenv.isDarwin; # https://hydra.nixos.org/build/130673870/nixlog/1
|
|
|
|
doCheck = false;
|
2019-09-06 21:33:32 +02:00
|
|
|
|
2020-08-20 11:14:02 +02:00
|
|
|
passthru.tests = { inherit (nixosTests) prometheus; };
|
|
|
|
|
2019-09-06 21:33:32 +02:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Service monitoring system and time series database";
|
|
|
|
homepage = "https://prometheus.io";
|
|
|
|
license = licenses.asl20;
|
2020-02-14 20:45:21 +01:00
|
|
|
maintainers = with maintainers; [ benley fpletz globin willibutz Frostman ];
|
2019-09-06 21:33:32 +02:00
|
|
|
platforms = platforms.unix;
|
2016-06-05 13:34:18 +02:00
|
|
|
};
|
|
|
|
}
|