nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 75 lines 1.6 kB view raw
1{ 2 stdenvNoCC, 3 fetchurl, 4 unzip, 5 lib, 6}: 7 8{ 9 pname, 10 versionPrefix ? "", 11 version, 12 zipHash, 13 meta ? { }, 14 passthru ? { }, 15 ... 16}@args: 17let 18 plat = stdenvNoCC.hostPlatform.system; 19in 20stdenvNoCC.mkDerivation ( 21 { 22 inherit pname versionPrefix version; 23 24 src = 25 if lib.isAttrs zipHash then 26 fetchurl { 27 name = "${pname}-${versionPrefix}${version}-${plat}.zip"; 28 hash = zipHash.${plat} or (throw "Unsupported system: ${plat}"); 29 url = 30 "https://grafana.com/api/plugins/${pname}/versions/${versionPrefix}${version}/download" 31 + { 32 x86_64-linux = "?os=linux&arch=amd64"; 33 aarch64-linux = "?os=linux&arch=arm64"; 34 x86_64-darwin = "?os=darwin&arch=amd64"; 35 aarch64-darwin = "?os=darwin&arch=arm64"; 36 } 37 .${plat} or (throw "Unsupported system: ${plat}"); 38 } 39 else 40 fetchurl { 41 name = "${pname}-${versionPrefix}${version}.zip"; 42 hash = zipHash; 43 url = "https://grafana.com/api/plugins/${pname}/versions/${versionPrefix}${version}/download"; 44 }; 45 46 nativeBuildInputs = [ unzip ]; 47 48 installPhase = '' 49 cp -R "." "$out" 50 chmod -R a-w "$out" 51 chmod u+w "$out" 52 ''; 53 54 passthru = { 55 updateScript = [ 56 ./update-grafana-plugin.sh 57 pname 58 ]; 59 } 60 // passthru; 61 62 meta = { 63 homepage = "https://grafana.com/grafana/plugins/${pname}"; 64 } 65 // meta; 66 } 67 // (removeAttrs args [ 68 "zipHash" 69 "pname" 70 "versionPrefix" 71 "version" 72 "sha256" 73 "meta" 74 ]) 75)