about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStepBroBD <Hi@StepBroBD.com>2023-03-06 22:57:23 -0700
committerStepBroBD <Hi@StepBroBD.com>2023-03-20 10:33:22 -0600
commit2b37a4822c57187c5fe50bc7480108571da7be7a (patch)
tree18bdf767b935370949ab4f8c26788e2dc76353cf
parent2c5b18dc0b33164a928e6830b69659e58d143d4d (diff)
downloadnixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.tar
nixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.tar.gz
nixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.tar.bz2
nixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.tar.lz
nixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.tar.xz
nixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.tar.zst
nixlib-2b37a4822c57187c5fe50bc7480108571da7be7a.zip
osu-lazer-bin: adding support for darwin systems
* osu-lazer-bin: added darwin binary distribution for osu-lazer

* osu-lazer-bin: sha256 and metadata changes

* maintainers: add stepbrobd

* osu-lazer-bin: fixed sha256 for x86_64-darwin

* osu-lazer-bin: adding support for darwin systems (delan/nixpkgs#2)

* osu-lazer-bin: follows formatting guideline provided by #219954

* osu-lazer-bin: fixed sha256 for all platforms using new update-bin.sh

* osu-lazer-bin: added a new update script for osu-lazer-bin

* osu-lazer-bin: passthru.updateScript

* osu-lazer-bin: add unzip to update script
-rw-r--r--maintainers/maintainer-list.nix10
-rwxr-xr-xpkgs/games/osu-lazer/update-bin.sh40
-rwxr-xr-xpkgs/games/osu-lazer/update.sh24
3 files changed, 54 insertions, 20 deletions
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 9681c7718017..ce149da00d08 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -14120,6 +14120,16 @@
     githubId = 22163194;
     name = "Stel Abrego";
   };
+  stepbrobd = {
+    name = "StepBroBD";
+    github = "StepBroBD";
+    githubId = 81826728;
+    email = "Hi@StepBroBD.com";
+    matrix = "@stepbrobd:matrix.org";
+    keys = [{
+      fingerprint = "5D8B FA8B 286A C2EF 6EE4  8598 F742 B72C 8926 1A51";
+    }];
+  };
   stephank = {
     email = "nix@stephank.nl";
     matrix = "@skochen:matrix.org";
diff --git a/pkgs/games/osu-lazer/update-bin.sh b/pkgs/games/osu-lazer/update-bin.sh
new file mode 100755
index 000000000000..a2ed671f232c
--- /dev/null
+++ b/pkgs/games/osu-lazer/update-bin.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -I nixpkgs=../../../. -i bash -p unzip curl jq common-updater-scripts
+set -eo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+
+bin_file="$(realpath ./bin.nix)"
+
+new_version="$(curl -s "https://api.github.com/repos/ppy/osu/releases?per_page=1" | jq -r '.[0].name')"
+old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./bin.nix)"
+if [[ "$new_version" == "$old_version" ]]; then
+    echo "Already up to date."
+    exit 0
+fi
+
+cd ../../..
+
+echo "Updating osu-lazer-bin from $old_version to $new_version..."
+sed -Ei.bak '/ *version = "/s/".+"/"'"$new_version"'"/' "$bin_file"
+rm "$bin_file.bak"
+
+for pair in \
+    'aarch64-darwin osu.app.Apple.Silicon.zip' \
+    'x86_64-darwin osu.app.Intel.zip' \
+    'x86_64-linux osu.AppImage'; do
+    set -- $pair
+    echo "Prefetching binary for $1..."
+    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")
+    if [[ "$1" == *"darwin"* ]]; then
+        store_path=$(jq -r '.storePath' <<<"$prefetch_output")
+        tmpdir=$(mktemp -d)
+        unzip -q "$store_path" -d "$tmpdir"
+        hash=$(nix --extra-experimental-features nix-command hash path "$tmpdir")
+        rm -r "$tmpdir"
+    else
+        hash=$(jq -r '.hash' <<<"$prefetch_output")
+    fi
+    echo "$1 ($2): sha256 = $hash"
+    sed -Ei.bak '/ *'"$1"' = /{N;N; s@("sha256-)[^;"]+@"'"$hash"'@}' "$bin_file"
+    rm "$bin_file.bak"
+done
diff --git a/pkgs/games/osu-lazer/update.sh b/pkgs/games/osu-lazer/update.sh
index 3a4c96000ea6..1ecca32d54a3 100755
--- a/pkgs/games/osu-lazer/update.sh
+++ b/pkgs/games/osu-lazer/update.sh
@@ -3,35 +3,19 @@
 set -eo pipefail
 cd "$(dirname "${BASH_SOURCE[0]}")"
 
-deps_file="$(realpath ./deps.nix)"
-bin_file="$(realpath ./bin.nix)"
+deps_file="$(realpath "./deps.nix")"
 
 new_version="$(curl -s "https://api.github.com/repos/ppy/osu/releases?per_page=1" | jq -r '.[0].name')"
 old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"
 if [[ "$new_version" == "$old_version" ]]; then
-  echo "Up to date"
-  exit 0
+    echo "Up to date"
+    exit 0
 fi
 
 cd ../../..
 
 if [[ "$1" != "--deps-only" ]]; then
-  update-source-version osu-lazer "$new_version"
-  sed -Ei.bak '/ *version = "/s/".+"/"'"$new_version"'"/' "$bin_file"
-  rm "$bin_file.bak"
-  for pair in \
-    'aarch64-darwin osu.app.Apple.Silicon.zip' \
-    'x86_64-darwin osu.app.Intel.zip' \
-    'x86_64-linux osu.AppImage' \
-  ; do
-    set -- $pair
-    nix-prefetch-url "https://github.com/ppy/osu/releases/download/$new_version/$2" | while read -r hash; do
-      nix --extra-experimental-features nix-command hash to-sri --type sha256 "$hash" | while read -r hash; do
-        sed -Ei.bak '/ *'"$1"' = "sha256-/s@".+"@"'"$hash"'"@' "$bin_file"
-        rm "$bin_file.bak"
-      done
-    done
-  done
+    update-source-version osu-lazer "$new_version"
 fi
 
 $(nix-build . -A osu-lazer.fetch-deps --no-out-link) "$deps_file"