biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / rover / update.sh
blob3914c9acb540f591f52eafe687bb425984023085
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnugrep gnused jq nix-prefetch
4 set -eu -o pipefail
6 dirname=$(realpath "$(dirname "$0")")
7 nixpkgs=$(realpath "${dirname}/../../../..")
9 old_rover_version=$(nix eval --raw -f "$nixpkgs" rover.version)
10 rover_url=https://api.github.com/repos/apollographql/rover/releases/latest
11 rover_tag=$(curl "$rover_url" | jq --raw-output ".tag_name")
12 rover_version="$(expr "$rover_tag" : 'v\(.*\)')"
14 if [[ "$old_rover_version" == "$rover_version" ]]; then
15 echo "rover is up-to-date: ${old_rover_version}"
16 exit 0
19 echo "Fetching rover"
20 rover_tar_url="https://github.com/apollographql/rover/archive/refs/tags/${rover_tag}.tar.gz"
22 read rover_hash
23 read repo
24 } < <(nix-prefetch-url "$rover_tar_url" --unpack --type sha256 --print-path)
26 # Convert hash to SRI representation
27 rover_sri_hash=$(nix hash to-sri --type sha256 "$rover_hash")
29 # Update rover version.
30 sed --in-place \
31 "s|version = \"[0-9.]*\"|version = \"$rover_version\"|" \
32 "$dirname/default.nix"
34 # Update rover hash.
35 sed --in-place \
36 "s|sha256 = \"[a-zA-Z0-9\/+-=]*\"|sha256 = \"$rover_sri_hash\"|" \
37 "$dirname/default.nix"
39 # Clear cargoSha256.
40 sed --in-place \
41 "s|cargoSha256 = \".*\"|cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"|" \
42 "$dirname/default.nix"
44 # Update cargoSha256
45 echo "Computing cargoSha256"
46 cargoSha256=$(
47 nix-prefetch "{ sha256 }: (import $nixpkgs {}).rover.cargoDeps.overrideAttrs (_: { outputHash = sha256; })"
49 sed --in-place \
50 "s|cargoSha256 = \".*\"|cargoSha256 = \"$cargoSha256\"|" \
51 "$dirname/default.nix"