nixpkgs/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix
Kartik Gokte d1b53c4f6f grafanaPlugins: added versionPrefix argument
Starting with v1.6.2, the plugin `grafana-oncall-app` changed the versioning schema in the upstream grafana plugin repository, adding a prefix "v" to every version. This creates a minor stylistic break in the current `grafanaPlugins` module, since it expects a version with just numbers and decimal points. By adding the versionPrefix arg, we preserve compatibility with other modules, while keeping with nixpkgs conventions.
2024-06-18 19:43:21 +05:30

42 lines
1.4 KiB
Nix

{ stdenvNoCC, fetchurl, unzip, lib }:
{ pname, versionPrefix ? "", version, zipHash, meta ? {}, passthru ? {}, ... }@args:
let plat = stdenvNoCC.hostPlatform.system; in stdenvNoCC.mkDerivation ({
inherit pname versionPrefix version;
src = if lib.isAttrs zipHash then
fetchurl {
name = "${pname}-${versionPrefix}${version}-${plat}.zip";
hash = zipHash.${plat} or (throw "Unsupported system: ${plat}");
url = "https://grafana.com/api/plugins/${pname}/versions/${versionPrefix}${version}/download" + {
x86_64-linux = "?os=linux&arch=amd64";
aarch64-linux = "?os=linux&arch=arm64";
x86_64-darwin = "?os=darwin&arch=amd64";
aarch64-darwin = "?os=darwin&arch=arm64";
}.${plat} or (throw "Unsupported system: ${plat}");
}
else
fetchurl {
name = "${pname}-${versionPrefix}${version}.zip";
hash = zipHash;
url = "https://grafana.com/api/plugins/${pname}/versions/${versionPrefix}${version}/download";
}
;
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 [ "zipHash" "pname" "versionPrefix" "version" "sha256" "meta" ]))