From 96ce8d59649f20c21b01f146bcd6b37aa14cd59e Mon Sep 17 00:00:00 2001 From: Yureka Date: Tue, 13 Jun 2023 11:10:28 +0200 Subject: grafanaPlugins.grafanaPlugin: add platform only when multiple zipHash are specified (#237513) --- .../monitoring/grafana/plugins/grafana-plugin.nix | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'pkgs/servers') diff --git a/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix b/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix index 25a381e2a8fa..7894e759b168 100644 --- a/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix +++ b/pkgs/servers/monitoring/grafana/plugins/grafana-plugin.nix @@ -4,17 +4,24 @@ let plat = stdenvNoCC.targetPlatform.system; in stdenvNoCC.mkDerivation ({ inherit pname version; - src = (fetchurl { - name = "${pname}-${version}-${plat}.zip"; - hash = if lib.isAttrs zipHash then zipHash.${plat} or (throw "unsupported system") else zipHash; - 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"); - }); + 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 ]; -- cgit 1.4.1