1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused nix-prefetch jq
5 URL
="https://github.com/fable-compiler/fable"
7 ROOT
="$(dirname "$
(readlink
-f "$0")")"
8 NIX_DRV
="$ROOT/default.nix"
9 if [ ! -f "$NIX_DRV" ]; then
10 echo "ERROR: cannot find default.nix in $ROOT"
18 trap clean_up EXIT SIGINT SIGTERM
19 PACKAGES
="$TMP/packages"
26 VER
=$
(curl
-s "https://api.github.com/repos/fable-compiler/fable/releases/latest" | jq
-r .tag_name |
grep -oP '\d+\.\d+\.\d+' )
28 CURRENT_VER
=$
(grep -oP '(?<=version = ")[^"]+' "$NIX_DRV")
29 if [[ "$CURRENT_VER" == "$VER" ]]; then
30 echo "$PKG is already up to date: $CURRENT_VER"
35 NUGET_URL
="$(curl -f "https
://api.nuget.org
/v
3/index.json
" | jq --raw-output '.resources[] | select(."@
type" == "PackageBaseAddress
/3.0.0")."@id
"')$PKG/$VER/$PKG.$VER.nupkg"
36 HASH
=$
(nix-hash
--to-sri --type sha256
"$(nix-prefetch-url "$NUGET_URL")")
38 sed -i "s/version = \".*\"/version = \"$VER\"/" "$NIX_DRV"
39 sed -i "s#nugetHash = \"sha256-.\{44\}\"#nugetHash = \"$HASH\"#" "$NIX_DRV"