From d1ffce933637937f20484ca380303a203f6beb20 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 24 Aug 2024 10:59:47 +0200 Subject: [PATCH] feat(grafana): jsonnet-based dashboards Signed-off-by: Raito Bezarius --- dashboards/default.nix | 21 +++++++++++++++++++++ flake.lock | 17 +++++++++++++++++ flake.nix | 3 +++ 3 files changed, 41 insertions(+) create mode 100644 dashboards/default.nix diff --git a/dashboards/default.nix b/dashboards/default.nix new file mode 100644 index 0000000..307ef9e --- /dev/null +++ b/dashboards/default.nix @@ -0,0 +1,21 @@ +{ stdenv, jsonnet, fetchFromGitHub, lib, ... }: +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: target: stdenv.mkDerivation { + name = "jsonnet-grafana-dashboard-${baseNameOf target}"; + src = dashboardSrc; + buildInputs = [ jsonnet ]; + buildPhase = '' + runHook preBuild + jsonnet -J ${grafonnet} --ext-code publish=false ${target} > $out + runHook postBuild + ''; + }; +} diff --git a/flake.lock b/flake.lock index 68e4df1..bf94103 100644 --- a/flake.lock +++ b/flake.lock @@ -385,6 +385,22 @@ "type": "github" } }, + "gerrit-dashboard": { + "flake": false, + "locked": { + "lastModified": 1724491526, + "narHash": "sha256-iBI8Rkcv3CYdZHz5hDI0104C+DgPZRh5K6Zcqz9iUWw=", + "ref": "refs/heads/master", + "rev": "d6badc64723b888a4cfa0cf966aec8b91dcb8a2b", + "revCount": 74, + "type": "git", + "url": "https://git.lix.systems/the-distro/gerrit-monitoring.git" + }, + "original": { + "type": "git", + "url": "https://git.lix.systems/the-distro/gerrit-monitoring.git" + } + }, "grapevine": { "inputs": { "attic": "attic", @@ -669,6 +685,7 @@ "agenix": "agenix", "buildbot-nix": "buildbot-nix", "colmena": "colmena", + "gerrit-dashboard": "gerrit-dashboard", "grapevine": "grapevine", "hydra": "hydra", "lix": [ diff --git a/flake.nix b/flake.nix index 7238a01..9349bcf 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,9 @@ nix-gerrit.url = "git+https://git.lix.systems/the-distro/nix-gerrit.git"; nix-gerrit.inputs.nixpkgs.follows = "nixpkgs"; + gerrit-dashboard.url = "git+https://git.lix.systems/the-distro/gerrit-monitoring.git"; + gerrit-dashboard.flake = false; + buildbot-nix.url = "git+https://git.lix.systems/lix-project/buildbot-nix.git?ref=refs/heads/non-flakes"; buildbot-nix.inputs.nixpkgs.follows = "nixpkgs";