Files
nixpkgs/pkgs/by-name/sc/scala-cli/update.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

61 lines
1.4 KiB
Nix

{
lib,
curl,
writeShellScript,
jq,
gnused,
git,
nix,
coreutils,
}:
{
platforms,
pname,
version,
}:
writeShellScript "${pname}-update-script" ''
set -o errexit
PATH=${
lib.makeBinPath [
curl
jq
gnused
git
nix
coreutils
]
}
latest_version=$(curl -s "https://api.github.com/repos/VirtusLab/scala-cli/releases?per_page=1" | jq ".[0].tag_name" --raw-output | sed 's/^v//')
if [[ "${version}" = "$latest_version" ]]; then
echo "The new version same as the old version."
exit 0
fi
nixpkgs=$(git rev-parse --show-toplevel)
sources_json="$nixpkgs/pkgs/by-name/sc/scala-cli/sources.json"
platform_assets=()
for platform in ${lib.concatStringsSep " " platforms}; do
asset=$(jq ".assets.\"$platform\".asset" --raw-output < $sources_json)
release_asset_url="https://github.com/Virtuslab/scala-cli/releases/download/v$latest_version/$asset"
asset_hash=$(nix-prefetch-url "$release_asset_url")
asset_object=$(jq --compact-output --null-input \
--arg asset "$asset" \
--arg sha256 "$asset_hash" \
--arg platform "$platform" \
'{asset: $asset, sha256: $sha256, platform: $platform}')
platform_assets+=($asset_object)
done
printf '%s\n' "''${platform_assets[@]}" | \
jq -s "map ( { (.platform): . | del(.platform) }) | add" | \
jq --arg version $latest_version \
'{ version: $version, assets: . }' > $sources_json
''