raito
024b431cbc
Add the gerrit dashboards as an example. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
44 lines
1.6 KiB
Nix
44 lines
1.6 KiB
Nix
{ gerrit-dashboard, stdenv, symlinkJoin, jsonnet, fetchFromGitHub, lib, ... }:
|
||
let
|
||
inherit (lib) concatMapStringsSep;
|
||
datasource-id = "mimir";
|
||
in
|
||
rec {
|
||
grafonnet = fetchFromGitHub {
|
||
owner = "grafana";
|
||
repo = "grafonnet-lib";
|
||
# TODO: figure out how to read the jsonnet lockfile
|
||
# and propagate this a bit cleverly.
|
||
rev = "a1d61cce1da59c71409b99b5c7568511fec661ea";
|
||
hash = "sha256-fs5JZJbcL6sQXBjYhp5eeRtjTFw0J1O/BcwBC8Vm9EM=";
|
||
};
|
||
buildJsonnetDashboards = dashboardSrc: targets: stdenv.mkDerivation {
|
||
name = "jsonnet-grafana-dashboards";
|
||
src = dashboardSrc;
|
||
buildInputs = [ jsonnet ];
|
||
buildPhase = ''
|
||
runHook preBuild
|
||
mkdir -p $out
|
||
${concatMapStringsSep "\n" (target: "jsonnet -J ${grafonnet} --ext-str datasource=${datasource-id} --ext-code publish=true $src/${target} > $out/${baseNameOf target}.json") targets}
|
||
runHook postBuild
|
||
'';
|
||
};
|
||
|
||
allDashboards = symlinkJoin {
|
||
name = "all-jsonnet-dashboards";
|
||
paths = [
|
||
(buildJsonnetDashboards gerrit-dashboard [
|
||
"dashboards/gerrit/caches/gerrit-caches.jsonnet"
|
||
"dashboards/gerrit/fetch-clone/gerrit-fetch-clone.jsonnet"
|
||
"dashboards/gerrit/fetch-clone/gerrit-phases.jsonnet"
|
||
"dashboards/gerrit/healthcheck/gerrit-healthcheck.jsonnet"
|
||
"dashboards/gerrit/latency/gerrit-push-latency.jsonnet"
|
||
"dashboards/gerrit/latency/gerrit-ui-actions-latency.jsonnet"
|
||
"dashboards/gerrit/overview/gerrit-overview.jsonnet"
|
||
"dashboards/gerrit/process/gerrit-process.jsonnet"
|
||
"dashboards/gerrit/queues/gerrit-queues.jsonnet"
|
||
])
|
||
];
|
||
};
|
||
}
|