From 7974a4b372959c33fcf2924b81338538073fe0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berk=20=C3=96zk=C3=BCt=C3=BCk?= Date: Fri, 8 Mar 2024 14:05:04 +0100 Subject: [PATCH] minigalaxy: 1.2.2 -> 1.3.0, cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sandro Jäckel --- pkgs/applications/misc/minigalaxy/default.nix | 53 ++++++++++--------- .../minigalaxy/inject-launcher-steam-run.diff | 32 +++++++++++ 2 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 pkgs/applications/misc/minigalaxy/inject-launcher-steam-run.diff diff --git a/pkgs/applications/misc/minigalaxy/default.nix b/pkgs/applications/misc/minigalaxy/default.nix index b8cdab22e8247..6ddef51e3e6d8 100644 --- a/pkgs/applications/misc/minigalaxy/default.nix +++ b/pkgs/applications/misc/minigalaxy/default.nix @@ -1,14 +1,13 @@ { lib , fetchFromGitHub -, docutils -, gettext , glibcLocales , glib-networking , gobject-introspection , gtk3 -, python3 +, libnotify , python3Packages , steam-run +, substituteAll , unzip , webkitgtk , wrapGAppsHook3 @@ -16,23 +15,29 @@ python3Packages.buildPythonApplication rec { pname = "minigalaxy"; - version = "1.2.2"; + version = "1.3.0"; src = fetchFromGitHub { owner = "sharkwouter"; - repo = pname; + repo = "minigalaxy"; rev = "refs/tags/${version}"; - sha256 = "sha256-bpNtdMYBl2dJ4PQsxkhm/Y+3A0dD/Y2XC0VaUYyRhvM="; + hash = "sha256-CMPBKnNrcjHVpsbBjY97FiygEJNG9jKHR/LoVMfuxG4="; }; - checkPhase = '' - runHook preCheck - env HOME=$PWD LC_ALL=en_US.UTF-8 pytest - runHook postCheck + patches = [ + (substituteAll { + src = ./inject-launcher-steam-run.diff; + steamrun = lib.getExe steam-run; + }) + ]; + + postPatch = '' + substituteInPlace minigalaxy/installer.py \ + --replace-fail '"unzip"' "\"${lib.getExe unzip}\"" \ + --replace-fail "'unzip'" "\"${lib.getExe unzip}\"" ''; nativeBuildInputs = [ - gettext wrapGAppsHook3 gobject-introspection ]; @@ -40,29 +45,29 @@ python3Packages.buildPythonApplication rec { buildInputs = [ glib-networking gtk3 + libnotify ]; nativeCheckInputs = with python3Packages; [ glibcLocales - pytest - tox + pytestCheckHook + simplejson ]; + preCheck = '' + export HOME=$(mktemp -d) + ''; + pythonPath = [ - docutils - python3.pkgs.pygobject3 - python3.pkgs.requests - python3.pkgs.setuptools - python3.pkgs.simplejson - steam-run - unzip + python3Packages.pygobject3 + python3Packages.requests webkitgtk ]; - # Run Linux games using the Steam Runtime by using steam-run in the wrapper - # FIXME: not working with makeBinaryWrapper - postFixup = '' - sed -e 's#exec -a "$0"#exec -a "$0" ${steam-run}/bin/steam-run#' -i $out/bin/minigalaxy + dontWrapGApps = true; + + preFixup = '' + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") ''; meta = with lib; { diff --git a/pkgs/applications/misc/minigalaxy/inject-launcher-steam-run.diff b/pkgs/applications/misc/minigalaxy/inject-launcher-steam-run.diff new file mode 100644 index 0000000000000..44850e9fbceab --- /dev/null +++ b/pkgs/applications/misc/minigalaxy/inject-launcher-steam-run.diff @@ -0,0 +1,32 @@ +diff --git a/minigalaxy/launcher.py b/minigalaxy/launcher.py +index 641db77..712c55b 100644 +--- a/minigalaxy/launcher.py ++++ b/minigalaxy/launcher.py +@@ -77,6 +77,7 @@ def get_execute_command(game) -> list: + if game.get_info("use_mangohud") is True: + exe_cmd.insert(0, "mangohud") + exe_cmd.insert(1, "--dlsym") ++ exe_cmd.insert(0, "@steamrun@") + exe_cmd = get_exe_cmd_with_var_command(game, exe_cmd) + logger.info("Launch command for %s: %s", game.name, " ".join(exe_cmd)) + return exe_cmd +diff --git a/tests/test_installer.py b/tests/test_installer.py +index 8e6cb76..a9d9f46 100644 +--- a/tests/test_installer.py ++++ b/tests/test_installer.py +@@ -296,13 +296,13 @@ def test_get_exec_line(self, mock_list_dir, mock_which): + mock_list_dir.return_value = ["data", "docs", "scummvm", "support", "beneath.ini", "gameinfo", "start.sh"] + + result1 = installer.get_exec_line(game1) +- self.assertEqual(result1, "scummvm -c beneath.ini") ++ self.assertEqual(result1, "@steamrun@ scummvm -c beneath.ini") + + game2 = Game("Blocks That Matter", install_dir="/home/test/GOG Games/Blocks That Matter", platform="linux") + mock_list_dir.return_value = ["data", "docs", "support", "gameinfo", "start.sh"] + + result2 = installer.get_exec_line(game2) +- self.assertEqual(result2, "./start.sh") ++ self.assertEqual(result2, "@steamrun@ ./start.sh") + + @mock.patch('os.path.getsize') + @mock.patch('os.listdir')