2019-12-04 14:42:07 +00:00
|
|
|
{ lib, go, buildGoPackage, fetchFromGitHub, mkYarnPackage }:
|
2016-06-05 12:34:18 +01:00
|
|
|
|
2019-12-04 14:42:07 +00:00
|
|
|
let
|
2020-07-30 10:20:00 +01:00
|
|
|
version = "2.19.3";
|
2018-03-11 00:08:34 +00:00
|
|
|
|
2019-09-06 20:33:32 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
rev = "v${version}";
|
|
|
|
owner = "prometheus";
|
|
|
|
repo = "prometheus";
|
2020-07-30 10:20:00 +01:00
|
|
|
sha256 = "0dlvhbxahdq0x0qa0gv1rc4y5dp6lx44w280rbm9279nv1nplffh";
|
2016-06-05 12:34:18 +01:00
|
|
|
};
|
|
|
|
|
2019-12-04 14:42:07 +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";
|
|
|
|
};
|
|
|
|
in buildGoPackage rec {
|
|
|
|
pname = "prometheus";
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
goPackagePath = "github.com/prometheus/prometheus";
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
ln -s ${webui.node_modules} web/ui/react-app/node_modules
|
|
|
|
ln -s ${webui} web/ui/static/react
|
|
|
|
'';
|
|
|
|
|
2019-09-06 20:33:32 +01:00
|
|
|
buildFlagsArray = let
|
|
|
|
t = "${goPackagePath}/vendor/github.com/prometheus/common/version";
|
2019-12-04 14:42:07 +00:00
|
|
|
in [
|
|
|
|
"-tags=builtinassets"
|
|
|
|
''
|
|
|
|
-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}
|
|
|
|
''
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
make -C go/src/${goPackagePath} assets
|
2019-09-06 20:33:32 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
preInstall = ''
|
2020-04-28 02:50:57 +01: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 20:33:32 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
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 20:33:32 +01:00
|
|
|
platforms = platforms.unix;
|
2016-06-05 12:34:18 +01:00
|
|
|
};
|
|
|
|
}
|