lol

gaugePlugins.makeGaugePlugin: init

authored by

Marie Ramlow and committed by
Yaya
842f64a0 60f5767c

+101
+6
pkgs/development/tools/gauge/plugins/default.nix
··· 1 + { lib, pkgs }: 2 + lib.makeScope pkgs.newScope (final: let 3 + inherit (final) callPackage; 4 + in { 5 + makeGaugePlugin = callPackage ./make-gauge-plugin.nix { }; 6 + })
+94
pkgs/development/tools/gauge/plugins/make-gauge-plugin.nix
··· 1 + { stdenvNoCC 2 + , fetchzip 3 + , lib 4 + , writeScript 5 + }: 6 + 7 + { pname 8 + , data 9 + , repo 10 + , releasePrefix 11 + , isCrossArch ? false 12 + , meta 13 + , ... 14 + } @ args: 15 + let 16 + otherArgs = lib.attrsets.removeAttrs args [ "pname" "data" "repo" "releasePrefix" "isMultiArch" ]; 17 + inherit (stdenvNoCC.hostPlatform) system; 18 + inherit (if isCrossArch then data else data.${system}) url hash; 19 + # Upstream uses a different naming scheme for platforms 20 + systemMap = { 21 + "x86_64-darwin" = "darwin.x86_64"; 22 + "aarch64-darwin" = "darwin.arm64"; 23 + "aarch64-linux" = "linux.arm64"; 24 + "x86_64-linux" = "linux.x86_64"; 25 + }; 26 + in 27 + stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate { 28 + pname = "gauge-plugin-${pname}"; 29 + inherit (data) version; 30 + 31 + src = fetchzip { 32 + inherit url hash; 33 + stripRoot = false; 34 + }; 35 + 36 + installPhase = '' 37 + mkdir -p "$out/share/gauge-plugins/${pname}/${finalAttrs.version}" 38 + cp -r . "$out/share/gauge-plugins/${pname}/${finalAttrs.version}" 39 + ''; 40 + 41 + passthru.updateScript = writeScript "update-${finalAttrs.pname}" '' 42 + #!/usr/bin/env nix-shell 43 + #!nix-shell -i bash -p curl nix-prefetch yq-go 44 + 45 + set -e 46 + 47 + dirname="pkgs/development/tools/gauge/plugins/${pname}" 48 + 49 + currentVersion=$(nix eval --raw -f default.nix gaugePlugins.${pname}.version) 50 + 51 + latestTag=$(curl -s ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/${repo}/releases/latest | yq ".tag_name") 52 + latestVersion="$(expr $latestTag : 'v\(.*\)')" 53 + 54 + tempfile=$(mktemp) 55 + 56 + if [[ "$FORCE_UPDATE" != "true" && "$currentVersion" == "$latestVersion" ]]; then 57 + echo "gauge-${pname} is up-to-date: ''${currentVersion}" 58 + exit 0 59 + fi 60 + 61 + yq -iPoj "{ \"version\": \"$latestVersion\" }" "$tempfile" 62 + 63 + updateSystem() { 64 + system=$1 65 + url=$2 66 + 67 + echo "Fetching hash for $system" 68 + hash=$(nix-prefetch-url --type sha256 $url --unpack) 69 + sriHash="$(nix hash to-sri --type sha256 $hash)" 70 + 71 + yq -iPoj '. + { "$system": { "url": "$url", "hash": "$sriHash" } }' "$tempfile" 72 + } 73 + 74 + updateSingle() { 75 + url=$1 76 + 77 + echo "Fetching hash" 78 + hash=$(nix-prefetch-url --type sha256 $url --unpack) 79 + sriHash="$(nix hash to-sri --type sha256 $hash)" 80 + 81 + yq -iPoj '. + { "url": "$url", "hash": "$sriHash" }' "$tempfile" 82 + } 83 + 84 + baseUrl="https://github.com/${repo}/releases/download/$latestTag/${releasePrefix}$latestVersion" 85 + 86 + ${if isCrossArch then 87 + "updateSingle \${baseUrl}.zip" 88 + else 89 + lib.concatStringsSep "\n" (map (platform: ''updateSystem "${platform}" "''${baseUrl}-${systemMap.${platform}}.zip"'') meta.platforms) 90 + } 91 + 92 + mv "$tempfile" "$dirname/data.json" 93 + ''; 94 + } otherArgs))
+1
pkgs/top-level/all-packages.nix
··· 8327 8327 gau = callPackage ../tools/security/gau { }; 8328 8328 8329 8329 gauge = callPackage ../development/tools/gauge { }; 8330 + gaugePlugins = recurseIntoAttrs (callPackage ../development/tools/gauge/plugins {}); 8330 8331 8331 8332 gawd = python3Packages.toPythonApplication python3Packages.gawd; 8332 8333