blob: 7894e759b168c10d3530193fe9878cdf9ed0adcc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{ stdenvNoCC, fetchurl, unzip, lib }:
{ pname, version, zipHash, meta ? {}, passthru ? {}, ... }@args:
let plat = stdenvNoCC.targetPlatform.system; in stdenvNoCC.mkDerivation ({
inherit pname version;
src = if lib.isAttrs zipHash then
fetchurl {
name = "${pname}-${version}-${plat}.zip";
hash = zipHash.${plat} or (throw "unsupported system");
url = "https://grafana.com/api/plugins/${pname}/versions/${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 "unknown system");
}
else
fetchurl {
name = "${pname}-${version}.zip";
hash = zipHash;
url = "https://grafana.com/api/plugins/${pname}/versions/${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" "version" "sha256" "meta" ]))
|