diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index d45dd9ccbd20..6f3a6a7562f9 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -14301,6 +14301,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/bin.nix b/pkgs/games/osu-lazer/bin.nix index cf17332785fd..20d09d83a094 100644 --- a/pkgs/games/osu-lazer/bin.nix +++ b/pkgs/games/osu-lazer/bin.nix @@ -1,28 +1,68 @@ -{ appimageTools, lib, fetchurl }: +{ lib +, stdenv +, fetchurl +, fetchzip +, appimageTools +}: -appimageTools.wrapType2 rec { +let pname = "osu-lazer-bin"; - version = "2023.301.0"; + version = "2023.305.0"; + name = "${pname}-${version}"; - src = fetchurl { - url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - sha256 = "sha256-0c74bGOY9f2K52xE7CZy/i3OfyCC+a6XGI30c6hI7jM="; + osu-lazer-bin-src = { + aarch64-darwin = { + url = "https://github.com/ppy/osu/releases/download/${version}/osu.app.Apple.Silicon.zip"; + sha256 = "sha256-nL5j0b4vD/tTYPPBLiMxiPWLHnP5hqco0DJ+7EZRSZY="; + }; + x86_64-darwin = { + url = "https://github.com/ppy/osu/releases/download/${version}/osu.app.Intel.zip"; + sha256 = "sha256-Er48BIzJlSzDaGb6IfhZoV62kj5GJ/rw9ifUw+ZCJkc="; + }; + x86_64-linux = { + url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; + sha256 = "sha256-W3XJ7HtJM5iFI8OOTTu8IBHMerZSCETHMemkoTislK8="; + }; + }.${stdenv.system} or (throw "${pname}-${version}: ${stdenv.system} is unsupported."); + + linux = appimageTools.wrapType2 rec { + inherit name pname version meta; + + src = fetchurl (osu-lazer-bin-src); + + extraPkgs = pkgs: with pkgs; [ icu ]; + + extraInstallCommands = + let contents = appimageTools.extract { inherit pname version src; }; + in + '' + mv -v $out/bin/${pname}-${version} $out/bin/osu\! + install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications + for i in 16 32 48 64 96 128 256 512 1024; do + install -D ${contents}/osu\!.png $out/share/icons/hicolor/''${i}x$i/apps/osu\!.png + done + ''; }; - extraPkgs = pkgs: with pkgs; [ icu ]; + darwin = stdenv.mkDerivation rec { + inherit name pname version meta; - extraInstallCommands = - let contents = appimageTools.extract { inherit pname version src; }; - in '' - mv -v $out/bin/${pname}-${version} $out/bin/osu\! - install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications - for i in 16 32 48 64 96 128 256 512 1024; do - install -D ${contents}/osu\!.png $out/share/icons/hicolor/''${i}x$i/apps/osu\!.png - done + src = fetchzip (osu-lazer-bin-src // { stripRoot = false; }); + + dontBuild = true; + dontFixup = true; + + installPhase = '' + runHook preInstall + APP_DIR="$out/Applications" + mkdir -p "$APP_DIR" + cp -r . "$APP_DIR" + runHook postInstall ''; + }; meta = with lib; { - description = "Rhythm is just a *click* away (AppImage version for score submission and multiplayer)"; + description = "Rhythm is just a *click* away (AppImage version for score submission and multiplayer, and binary distribution for Darwin systems)"; homepage = "https://osu.ppy.sh"; license = with licenses; [ mit @@ -30,8 +70,14 @@ appimageTools.wrapType2 rec { unfreeRedistributable # osu-framework contains libbass.so in repository ]; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - maintainers = [ maintainers.delan ]; + maintainers = with maintainers; [ delan stepbrobd ]; mainProgram = "osu!"; - platforms = [ "x86_64-linux" ]; + platforms = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ]; }; -} + + passthru.updateScript = ./update-bin.sh; +in +if stdenv.isDarwin +then darwin +else linux + diff --git a/pkgs/games/osu-lazer/default.nix b/pkgs/games/osu-lazer/default.nix index f3aea2a333af..1de04bc06b94 100644 --- a/pkgs/games/osu-lazer/default.nix +++ b/pkgs/games/osu-lazer/default.nix @@ -17,13 +17,13 @@ buildDotnetModule rec { pname = "osu-lazer"; - version = "2023.301.0"; + version = "2023.305.0"; src = fetchFromGitHub { owner = "ppy"; repo = "osu"; rev = version; - sha256 = "sha256-SUVxe3PdUch8NYR7X4fatbmSpyYewI69usBDICcSq3s="; + sha256 = "sha256-gkAHAiTwCYXTSIHrM3WWLBLbC7S9x1cAaEhSYvtNsvQ="; }; projectFile = "osu.Desktop/osu.Desktop.csproj"; 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 df1dbcc3c519..1ecca32d54a3 100755 --- a/pkgs/games/osu-lazer/update.sh +++ b/pkgs/games/osu-lazer/update.sh @@ -8,8 +8,8 @@ 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 ../../..