From bfc755d4d0e14a159b77b82246ffe651fa52955b Mon Sep 17 00:00:00 2001 From: Johannes Maier Date: Sat, 18 Jun 2022 13:54:28 +0200 Subject: [PATCH 1/2] umoria: fix savegame handling It was impossible to continue a saved character before, as the `cleanup` function would remove the whole temporary RUNDIR, including the actual save file. umoria allows passing a custom save file location, which now points to the already-used data directory ~/.umoria. Fixes #178136 --- pkgs/games/umoria/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/games/umoria/default.nix b/pkgs/games/umoria/default.nix index 1114d47b7be..03cdf4eab9d 100644 --- a/pkgs/games/umoria/default.nix +++ b/pkgs/games/umoria/default.nix @@ -8,7 +8,7 @@ }: let - savesDir = "~/.umoria/"; + savesDir = "~/.umoria"; in gcc9Stdenv.mkDerivation rec { pname = "umoria"; @@ -55,7 +55,7 @@ gcc9Stdenv.mkDerivation rec { [[ ! -f ${savesDir}/scores.dat ]] && touch ${savesDir}/scores.dat ln -s ${savesDir}/scores.dat scores.dat - $out/.umoria-unwrapped + $out/.umoria-unwrapped ${savesDir}/game.sav EOF chmod +x $out/bin/umoria From acf302428e6129d88e8282736a4d76792a79362e Mon Sep 17 00:00:00 2001 From: Johannes Maier Date: Sat, 18 Jun 2022 14:18:00 +0200 Subject: [PATCH 2/2] umoria: refactor and extend - Simplify some symlinking - Don't remove the temporary run directory: umoria allows for dumping character info, which would be in there and inaccessible after saving the game otherwise. The system takes care of cleaning up the temporary directory anyway. - Allow passing arguments to the wrapped executable, allowing using different save directories, passing game seeds, checking out highscores, etc. --- pkgs/games/umoria/default.nix | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pkgs/games/umoria/default.nix b/pkgs/games/umoria/default.nix index 03cdf4eab9d..13ec037afba 100644 --- a/pkgs/games/umoria/default.nix +++ b/pkgs/games/umoria/default.nix @@ -38,24 +38,22 @@ gcc9Stdenv.mkDerivation rec { RUNDIR=\$(mktemp -d) - cleanup() { - rm -rf \$RUNDIR - } - - trap cleanup EXIT + # Print the directory, so users have access to dumps, and let the system + # take care of cleaning up temp files. + echo "Running umoria in \$RUNDIR" cd \$RUNDIR - mkdir data - - for i in $out/data/*; do - ln -s \$i "data/\$(basename \$i)" - done + ln -sn $out/data \$RUNDIR/data mkdir -p ${savesDir} [[ ! -f ${savesDir}/scores.dat ]] && touch ${savesDir}/scores.dat ln -s ${savesDir}/scores.dat scores.dat - $out/.umoria-unwrapped ${savesDir}/game.sav + if [ \$# -eq 0 ]; then + $out/.umoria-unwrapped ${savesDir}/game.sav + else + $out/.umoria-unwrapped "\$@" + fi EOF chmod +x $out/bin/umoria @@ -74,7 +72,7 @@ gcc9Stdenv.mkDerivation rec { ''; platforms = platforms.unix; badPlatforms = [ "aarch64-darwin" ]; - maintainers = [ maintainers.aciceri ]; + maintainers = with maintainers; [ aciceri kenran ]; license = licenses.gpl3Plus; }; }