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:
parent
75513fb361
commit
3ba1a06a78
7
pkgs/servers/monitoring/grafana/plugins/default.nix
Normal file
7
pkgs/servers/monitoring/grafana/plugins/default.nix
Normal file
@ -0,0 +1,7 @@
|
||||
{ newScope, pkgs }:
|
||||
|
||||
let
|
||||
callPackage = newScope (pkgs // plugins);
|
||||
plugins = import ./plugins.nix { inherit callPackage; };
|
||||
in
|
||||
plugins
|
28
pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix
Normal file
28
pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix
Normal 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" ]))
|
6
pkgs/servers/monitoring/grafana/plugins/plugins.nix
Normal file
6
pkgs/servers/monitoring/grafana/plugins/plugins.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{ callPackage }:
|
||||
{
|
||||
inherit callPackage;
|
||||
|
||||
grafanaPlugin = callPackage ./grafana-plugin.nix { };
|
||||
}
|
8
pkgs/servers/monitoring/grafana/plugins/update-grafana-plugin.sh
Executable file
8
pkgs/servers/monitoring/grafana/plugins/update-grafana-plugin.sh
Executable 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"
|
@ -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 { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user