forked from fufexan/nix-gaming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osu-lazer-bin: use overrideAttrs with nixpkgs' package
- Loading branch information
1 parent
9bde4ef
commit eb34457
Showing
4 changed files
with
89 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,40 @@ | ||
{ | ||
lib, | ||
pins, | ||
SDL2, | ||
alsa-lib, | ||
appimageTools, | ||
autoPatchelfHook, | ||
fetchurl, | ||
ffmpeg_4, | ||
gamemode, | ||
icu, | ||
libkrb5, | ||
lttng-ust, | ||
makeDesktopItem, | ||
makeWrapper, | ||
numactl, | ||
openssl, | ||
stdenvNoCC, | ||
symlinkJoin, | ||
vulkan-loader, | ||
pipewire_latency ? "64/48000", # reasonable default | ||
gmrun_enable ? true, # keep this flag for compatibility | ||
command_prefix ? | ||
if gmrun_enable | ||
# won't hurt users even if they don't have it set up | ||
then "${gamemode}/bin/gamemoderun" | ||
else null, | ||
osu-mime, | ||
}: let | ||
pname = "osu-lazer-bin"; | ||
fetchzip, | ||
osu-lazer-bin, | ||
pins, | ||
stdenv, | ||
}: | ||
osu-lazer-bin.overrideAttrs (oldAttrs: rec { | ||
inherit (pins.osu) version; | ||
|
||
appimageBin = fetchurl { | ||
url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; | ||
inherit (builtins.fromJSON (builtins.readFile ./info.json)) hash; | ||
}; | ||
extracted = appimageTools.extract { | ||
inherit version; | ||
pname = "osu.AppImage"; | ||
src = appimageBin; | ||
}; | ||
derivation = stdenvNoCC.mkDerivation rec { | ||
inherit version pname; | ||
src = extracted; | ||
buildInputs = [ | ||
SDL2 | ||
alsa-lib | ||
ffmpeg_4 | ||
icu | ||
libkrb5 | ||
lttng-ust | ||
numactl | ||
openssl | ||
vulkan-loader | ||
]; | ||
nativeBuildInputs = [ | ||
autoPatchelfHook | ||
makeWrapper | ||
]; | ||
autoPatchelfIgnoreMissingDeps = true; | ||
installPhase = '' | ||
runHook preInstall | ||
install -d $out/bin $out/lib | ||
install osu\!.png $out/osu.png | ||
cp -r usr/bin $out/lib/osu | ||
makeWrapper $out/lib/osu/osu\! $out/bin/osu-lazer \ | ||
--set COMPlus_GCGen0MaxBudget "600000" \ | ||
--set PIPEWIRE_LATENCY "${pipewire_latency}" \ | ||
--set vblank_mode "0" \ | ||
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath buildInputs}" | ||
${ | ||
# a hack to infiltrate the command in the wrapper | ||
lib.optionalString (builtins.isString command_prefix) '' | ||
sed -i '$s:exec :exec ${command_prefix} :' $out/bin/osu-lazer | ||
'' | ||
} | ||
runHook postInstall | ||
''; | ||
fixupPhase = '' | ||
runHook preFixup | ||
ln -sft $out/lib/osu ${SDL2}/lib/libSDL2${stdenvNoCC.hostPlatform.extensions.sharedLibrary} | ||
runHook postFixup | ||
''; | ||
}; | ||
desktopItem = makeDesktopItem { | ||
name = pname; | ||
exec = "${derivation.outPath}/bin/osu-lazer %U"; | ||
icon = "${derivation.outPath}/osu.png"; | ||
comment = "A free-to-win rhythm game. Rhythm is just a *click* away!"; | ||
desktopName = "osu!"; | ||
categories = ["Game"]; | ||
mimeTypes = [ | ||
"application/x-osu-skin-archive" | ||
"application/x-osu-replay" | ||
"application/x-osu-beatmap-archive" | ||
"x-scheme-handler/osu" | ||
]; | ||
}; | ||
in | ||
symlinkJoin { | ||
name = "${pname}-${version}"; | ||
paths = [ | ||
derivation | ||
desktopItem | ||
osu-mime | ||
]; | ||
# TODO: I didn't figure out how to use lib.resursiveUpdate here, | ||
# so I ended up copying the entire thing. | ||
|
||
# TODO: ./info.json's order is wrong, for some reason. | ||
# we should make it a set instead of a list, like `jq -r '.aarch64-darwin.hash'` | ||
# but I don't know how to do it in bash, at the moment it just works (tm). | ||
src = let | ||
baseUrl = "https://github.com/ppy/osu/releases/download/${version}"; | ||
in | ||
{ | ||
aarch64-darwin = fetchzip { | ||
inherit (builtins.elemAt (builtins.fromJSON (builtins.readFile ./info.json)) 2) hash; | ||
url = "${baseUrl}/osu.app.Apple.Silicon.zip"; | ||
striproot = false; | ||
}; | ||
x86_64-darwin = fetchzip { | ||
inherit (builtins.elemAt (builtins.fromJSON (builtins.readFile ./info.json)) 1) hash; | ||
url = "${baseUrl}/osu.app.Intel.zip"; | ||
striproot = false; | ||
}; | ||
x86_64-linux = fetchurl { | ||
inherit (builtins.elemAt (builtins.fromJSON (builtins.readFile ./info.json)) 0) hash; | ||
url = "${baseUrl}/osu.AppImage"; | ||
}; | ||
} | ||
.${stdenv.system} | ||
or (throw "${oldAttrs.pname}-${version}: ${stdenv.system} is unsupported."); | ||
|
||
meta = { | ||
description = "Rhythm is just a *click* away"; | ||
longDescription = "osu-lazer extracted from the official AppImage to retain multiplayer support."; | ||
homepage = "https://osu.ppy.sh"; | ||
license = with lib.licenses; [ | ||
mit | ||
cc-by-nc-40 | ||
unfreeRedistributable # osu-framework contains libbass.so in repository | ||
]; | ||
mainProgram = "osu-lazer"; | ||
passthru.updateScript = ./update.sh; | ||
platforms = ["x86_64-linux"]; | ||
}; | ||
} | ||
passthru.updateScript = ./update.sh; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
{ | ||
"hash": "sha256-aNG6s942iTKyvM1XolMqmMs8XxoRYC/ZddCCJl0OtTE=", | ||
"storePath": "/nix/store/svxz8clgl17k8wl40f0bblsl8nj3pbw1-osu.AppImage", | ||
"version": "2024.131.0" | ||
} | ||
[ | ||
{ | ||
"hash": "sha256-aNG6s942iTKyvM1XolMqmMs8XxoRYC/ZddCCJl0OtTE=", | ||
"storePath": "/nix/store/1s1kzc8bry7kb3m5vi7gqd0lmlvgf94p-svxz8clgl17k8wl40f0bblsl8nj3pbw1-osu.AppImage", | ||
"version": "2024.131.0" | ||
}, | ||
{ | ||
"hash": "sha256-oiWQp7c9//W4g0csNIseDU0R5l26SuaDWmq9NoYLWgc=", | ||
"storePath": "/nix/store/qkbsxxpn56l38kik6wg6n2bskbh1h8sf-p4rrmqnn35hsjwihpdvhjy0kxmspxmgn-osu.app.Intel.zip", | ||
"version": "2024.131.0" | ||
}, | ||
{ | ||
"hash": "sha256-ohZ6Cmhjlc57/tu0l/3vUz3RfHJzj2sFhM+L9xoICGk=", | ||
"storePath": "/nix/store/8sbz67psx4xbw9nm1jcqw5sbpd7prwys-xwnckc0a6cvw6xd99m110sr5vginysjy-osu.app.Apple.Silicon.zip", | ||
"version": "2024.131.0" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
#!/usr/bin/env -S nix shell nixpkgs#jq -c bash | ||
|
||
info="pkgs/osu-lazer-bin/info.json" | ||
packagePath="pkgs/osu-lazer-bin" | ||
version=$(jq -r '.pins.osu.version' npins/sources.json) | ||
oldversion=$(jq -r '.version' "$info") | ||
url="https://github.com/ppy/osu/releases/download/${version}/osu.AppImage" | ||
oldversion=$(jq -r '.[0].version' "$packagePath/info.json") | ||
|
||
if [ "$oldversion" != "$version" ]; then | ||
if output=$(nix store prefetch-file "$url" --json); then | ||
jq --arg version "$version" '.version = $version' <<<"$output" >"$info" | ||
else | ||
echo "osu!lazer has a non-release update" | ||
fi | ||
else | ||
echo "osu!lazer is up to date." | ||
fi | ||
# Concat them to make a new url | ||
#baseUrl="https://github.com/ppy/osu/releases/download/${version}/" | ||
baseUrl="file:///nix/store" | ||
declare -A filenames=( | ||
#[aarch64darwin]="osu.app.Apple.Silicon.zip" | ||
#[x86_64darwin]="osu.app.Intel.zip" | ||
#[x86_64linux]="osu.AppImage" | ||
[aarch64darwin]="xwnckc0a6cvw6xd99m110sr5vginysjy-osu.app.Apple.Silicon.zip" | ||
[x86_64darwin]="p4rrmqnn35hsjwihpdvhjy0kxmspxmgn-osu.app.Intel.zip" | ||
[x86_64linux]="svxz8clgl17k8wl40f0bblsl8nj3pbw1-osu.AppImage" | ||
) | ||
|
||
#if [ "$oldversion" != "$version" ]; then | ||
for arch in "${!filenames[@]}"; do | ||
arch_value=${filenames[$arch]} | ||
output_json="${packagePath}/${arch}-info.json" | ||
if output=$(nix store prefetch-file "${baseUrl}/${arch_value}" --json); then | ||
jq --arg version "$version" '.version = $version' <<< "$output" > $output_json | ||
json_array+=($output_json) | ||
else | ||
echo "osu!lazer on $arch has a non-release update" | ||
fi | ||
done | ||
|
||
# Merge the JSON files into a single JSON list | ||
jq -s '.' "${json_array[@]}" > "$packagePath/info.json" | ||
|
||
# Cleanup the architecture-specific JSON files | ||
for arch in "${!filenames[@]}"; do | ||
rm "${packagePath}/${arch}-info.json" | ||
done | ||
|
||
#else | ||
# echo "osu!lazer is up to date." | ||
#fi |