1 #!/usr/bin/env nix-shell
2 #!nix-shell -I nixpkgs=./. -i bash -p unzip curl jq common-updater-scripts
4 cd "$(dirname "${BASH_SOURCE[0]}")"
6 bin_file
="$(realpath ./package.nix)"
8 new_version
="$(curl -s "https
://api.github.com
/repos
/ppy
/osu
/releases?per_page
=1" | jq -r '.[0].name')"
9 old_version
="$(sed -nE 's/\s*version = "(.
*)".*/\1/p' ./package.nix)"
10 if [[ "$new_version" == "$old_version" ]]; then
11 echo "Already up to date."
17 echo "Updating osu-lazer-bin from $old_version to $new_version..."
18 sed -Ei.bak
'/ *version = "/s/".+"/"'"$new_version"'"/' "$bin_file"
22 'aarch64-darwin osu.app.Apple.Silicon.zip' \
23 'x86_64-darwin osu.app.Intel.zip' \
24 'x86_64-linux osu.AppImage'; do
26 echo "Prefetching binary for $1..."
27 prefetch_output
=$
(nix
--extra-experimental-features nix-command store prefetch-file
--json --hash-type sha256
"https://github.com/ppy/osu/releases/download/$new_version/$2")
28 if [[ "$1" == *"darwin"* ]]; then
29 store_path
=$
(jq
-r '.storePath' <<<"$prefetch_output")
31 unzip -q "$store_path" -d "$tmpdir"
32 hash=$
(nix
--extra-experimental-features nix-command
hash path
"$tmpdir")
35 hash=$
(jq
-r '.hash' <<<"$prefetch_output")
37 echo "$1 ($2): hash = $hash"
38 sed -Ei.bak
'/ *'"$1"' = /{N;N; s@("sha256-)[^;"]+@"'"$hash"'@}' "$bin_file"