grafanaPlugins: init

This contains the base infrastructure (including a basic update script)
for maintaining Grafana plugins inside Nix, which, in a subsequent
commit, will be used for allowing the NixOS Grafana module to
automatically install plugins.
This commit is contained in:
Luke Granger-Brown 2020-12-30 17:30:54 +00:00
parent 75513fb361
commit 3ba1a06a78
5 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,7 @@
{ newScope, pkgs }:
let
callPackage = newScope (pkgs // plugins);
plugins = import ./plugins.nix { inherit callPackage; };
in
plugins

View File

@ -0,0 +1,28 @@
{ stdenvNoCC, fetchurl, unzip }:
{ pname, version, zipHash, meta ? {}, passthru ? {}, ... }@args:
stdenvNoCC.mkDerivation ({
inherit pname version;
src = fetchurl {
name = "${pname}-${version}.zip";
url = "https://grafana.com/api/plugins/${pname}/versions/${version}/download";
hash = zipHash;
};
nativeBuildInputs = [ unzip ];
installPhase = ''
cp -R "." "$out"
chmod -R a-w "$out"
chmod u+w "$out"
'';
passthru = {
updateScript = [ ./update-grafana-plugin.sh pname ];
} // passthru;
meta = {
homepage = "https://grafana.com/grafana/plugins/${pname}";
} // meta;
} // (builtins.removeAttrs args [ "pname" "version" "sha256" "meta" ]))

View File

@ -0,0 +1,6 @@
{ callPackage }:
{
inherit callPackage;
grafanaPlugin = callPackage ./grafana-plugin.nix { };
}

View File

@ -0,0 +1,8 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts
set -eu -o pipefail
readonly plugin_name="$1"
readonly latest_version="$(curl "https://grafana.com/api/plugins/${plugin_name}" | jq -r .version)"
update-source-version "grafanaPlugins.${plugin_name}" "$latest_version"

View File

@ -17164,6 +17164,7 @@ in
gofish = callPackage ../servers/gopher/gofish { };
grafana = callPackage ../servers/monitoring/grafana { };
grafanaPlugins = dontRecurseIntoAttrs (callPackage ../servers/monitoring/grafana/plugins { });
grafana-loki = callPackage ../servers/monitoring/loki { };