2021-07-24 12:14:16 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, go
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, mkYarnPackage
|
|
|
|
, nixosTests
|
2020-12-25 13:55:36 +00:00
|
|
|
, fetchpatch
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2021-05-20 23:08:51 +00:00
|
|
|
version = "2.27.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
rev = "v${version}";
|
|
|
|
owner = "prometheus";
|
|
|
|
repo = "prometheus";
|
2021-05-20 23:08:51 +00:00
|
|
|
sha256 = "0836ygyvld5skjycd7366i6vyf451s6cay5ng6c2fwq0skvp2gj2";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
goPackagePath = "github.com/prometheus/prometheus";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
webui = mkYarnPackage {
|
|
|
|
src = "${src}/web/ui/react-app";
|
|
|
|
packageJSON = ./webui-package.json;
|
|
|
|
yarnNix = ./webui-yarndeps.nix;
|
|
|
|
|
|
|
|
# The standard yarn2nix directory management causes build failures with
|
|
|
|
# Prometheus's webui due to using relative imports into node_modules. Use
|
|
|
|
# an extremely simplified version of it instead.
|
|
|
|
configurePhase = "ln -s $node_modules node_modules";
|
|
|
|
buildPhase = "PUBLIC_URL=. yarn build";
|
|
|
|
installPhase = "mv build $out";
|
|
|
|
distPhase = "true";
|
|
|
|
};
|
2021-07-24 12:14:16 +00:00
|
|
|
in
|
|
|
|
buildGoModule rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "prometheus";
|
|
|
|
inherit src version;
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
vendorSha256 = "0dq3p7hga7m1aq78har5rr136hlb0kp8zhh2wzqlkxrk1f33w54p";
|
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 = ''
|
|
|
|
ln -s ${webui.node_modules} web/ui/react-app/node_modules
|
|
|
|
ln -s ${webui} web/ui/static/react
|
|
|
|
'';
|
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
buildFlags = "-tags=builtinassets";
|
2021-07-24 12:14:16 +00:00
|
|
|
buildFlagsArray =
|
|
|
|
let
|
|
|
|
t = "${goPackagePath}/vendor/github.com/prometheus/common/version";
|
|
|
|
in
|
|
|
|
[
|
|
|
|
''
|
|
|
|
-ldflags=
|
|
|
|
-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}
|
|
|
|
''
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
# only run this in the real build, not during the vendor build
|
|
|
|
# this should probably be fixed in buildGoModule
|
2020-04-24 23:36:52 +00:00
|
|
|
preBuild = ''
|
2021-05-20 23:08:51 +00:00
|
|
|
if [ -d vendor ]; then make assets; fi
|
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
|
|
|
'';
|
|
|
|
|
2021-07-24 12:14:16 +00:00
|
|
|
# doCheck = !stdenv.isDarwin; # https://hydra.nixos.org/build/130673870/nixlog/1
|
|
|
|
doCheck = false;
|
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;
|
|
|
|
maintainers = with maintainers; [ benley fpletz globin willibutz Frostman ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|