From 56b35d8859cf62ad4402e75b3e3e3215b868eb9a Mon Sep 17 00:00:00 2001 From: MetaDark Date: Thu, 7 Nov 2019 09:38:33 -0500 Subject: [PATCH 1/4] protontricks: support proton wine with steam-run --- .../protontricks/default.nix | 39 ++-- .../protontricks/steam-run.patch | 211 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 9 +- 3 files changed, 232 insertions(+), 27 deletions(-) create mode 100644 pkgs/tools/package-management/protontricks/steam-run.patch diff --git a/pkgs/tools/package-management/protontricks/default.nix b/pkgs/tools/package-management/protontricks/default.nix index 02bc599f47d..17bf1ba2f11 100644 --- a/pkgs/tools/package-management/protontricks/default.nix +++ b/pkgs/tools/package-management/protontricks/default.nix @@ -1,13 +1,12 @@ -{ stdenv -, lib +{ lib , buildPythonApplication , fetchFromGitHub , setuptools_scm , vdf -, wine +, steam-run , winetricks , zenity -, pytest +, pytestCheckHook }: buildPythonApplication rec { @@ -21,11 +20,10 @@ buildPythonApplication rec { sha256 = "0ri4phi1rna9snrxa6gl23walyack09mgax7zpjqfpxivwls3ach"; }; - # Fix interpreter in mock run.sh for tests - postPatch = '' - substituteInPlace tests/conftest.py \ - --replace '#!/bin/bash' '#!${stdenv.shell}' \ - ''; + patches = [ + # Use steam-run to run Proton binaries + ./steam-run.patch + ]; preBuild = '' export SETUPTOOLS_SCM_PRETEND_VERSION="${version}" @@ -34,22 +32,21 @@ buildPythonApplication rec { nativeBuildInputs = [ setuptools_scm ]; propagatedBuildInputs = [ vdf ]; - # The wine install shipped with Proton must run under steam's - # chrootenv, but winetricks and zenity break when running under - # it. See https://github.com/NixOS/nix/issues/902. - # - # The current workaround is to use wine from nixpkgs makeWrapperArgs = [ - "--set STEAM_RUNTIME 0" - "--set-default WINE ${wine}/bin/wine" - "--set-default WINESERVER ${wine}/bin/wineserver" - "--prefix PATH : ${lib.makeBinPath [ winetricks zenity ]}" + "--prefix PATH : ${lib.makeBinPath [ + steam-run + winetricks + zenity + ]}" ]; - checkInputs = [ pytest ]; - checkPhase = "pytest"; + checkInputs = [ pytestCheckHook ]; + disabledTests = [ + # Steam runtime is hard-coded with steam-run.patch and can't be configured + "test_run_steam_runtime_not_found" + ]; - meta = with stdenv.lib; { + meta = with lib; { description = "A simple wrapper for running Winetricks commands for Proton-enabled games"; homepage = "https://github.com/Matoking/protontricks"; license = licenses.gpl3; diff --git a/pkgs/tools/package-management/protontricks/steam-run.patch b/pkgs/tools/package-management/protontricks/steam-run.patch new file mode 100644 index 00000000000..0728213dc7d --- /dev/null +++ b/pkgs/tools/package-management/protontricks/steam-run.patch @@ -0,0 +1,211 @@ +diff --git a/src/protontricks/cli.py b/src/protontricks/cli.py +index 6506dae..2f762c9 100755 +--- a/src/protontricks/cli.py ++++ b/src/protontricks/cli.py +@@ -14,7 +14,7 @@ import os + import logging + + from . import __version__ +-from .steam import (find_proton_app, find_steam_path, find_steam_runtime_path, ++from .steam import (find_proton_app, find_steam_path, + get_steam_apps, get_steam_lib_paths) + from .winetricks import get_winetricks_path + from .gui import select_steam_app_with_gui +@@ -75,8 +75,7 @@ def main(args=None): + "WINE: path to a custom 'wine' executable\n" + "WINESERVER: path to a custom 'wineserver' executable\n" + "STEAM_RUNTIME: 1 = enable Steam Runtime, 0 = disable Steam " +- "Runtime, valid path = custom Steam Runtime path, " +- "empty = enable automatically (default)" ++ "Runtime, empty = enable automatically (default)" + ), + formatter_class=argparse.RawTextHelpFormatter + ) +@@ -133,14 +132,10 @@ def main(args=None): + sys.exit(-1) + + # 2. Find Steam Runtime if enabled +- steam_runtime_path = None ++ steam_runtime = False + + if os.environ.get("STEAM_RUNTIME", "") != "0" and not args.no_runtime: +- steam_runtime_path = find_steam_runtime_path(steam_root=steam_root) +- +- if not steam_runtime_path: +- print("Steam Runtime was enabled but couldn't be found!") +- sys.exit(-1) ++ steam_runtime = True + else: + logger.info("Steam Runtime disabled.") + +@@ -194,7 +189,7 @@ def main(args=None): + winetricks_path=winetricks_path, + proton_app=proton_app, + steam_app=steam_app, +- steam_runtime_path=steam_runtime_path, ++ steam_runtime=steam_runtime, + command=[winetricks_path, "--gui"] + ) + return +@@ -261,7 +256,7 @@ def main(args=None): + winetricks_path=winetricks_path, + proton_app=proton_app, + steam_app=steam_app, +- steam_runtime_path=steam_runtime_path, ++ steam_runtime=steam_runtime, + command=[winetricks_path] + args.winetricks_command) + elif args.command: + run_command( +@@ -269,7 +264,7 @@ def main(args=None): + proton_app=proton_app, + steam_app=steam_app, + command=args.command, +- steam_runtime_path=steam_runtime_path, ++ steam_runtime=steam_runtime, + # Pass the command directly into the shell *without* + # escaping it + cwd=steam_app.install_path, +diff --git a/src/protontricks/steam.py b/src/protontricks/steam.py +index 0d3670e..d01cabe 100644 +--- a/src/protontricks/steam.py ++++ b/src/protontricks/steam.py +@@ -12,7 +12,7 @@ from .util import lower_dict + + __all__ = ( + "COMMON_STEAM_DIRS", "SteamApp", "find_steam_path", +- "find_steam_proton_app", "find_proton_app", "find_steam_runtime_path", ++ "find_steam_proton_app", "find_proton_app", + "find_appid_proton_prefix", "get_steam_lib_paths", "get_steam_apps", + "get_custom_proton_installations" + ) +@@ -207,38 +207,6 @@ def find_steam_path(): + return None, None + + +-def find_steam_runtime_path(steam_root): +- """ +- Find the Steam Runtime either using the STEAM_RUNTIME env or +- steam_root +- """ +- env_steam_runtime = os.environ.get("STEAM_RUNTIME", "") +- +- if env_steam_runtime == "0": +- # User has disabled Steam Runtime +- logger.info("STEAM_RUNTIME is 0. Disabling Steam Runtime.") +- return None +- elif os.path.isdir(env_steam_runtime): +- # User has a custom Steam Runtime +- logger.info( +- "Using custom Steam Runtime at %s", env_steam_runtime) +- return env_steam_runtime +- elif env_steam_runtime in ["1", ""]: +- # User has enabled Steam Runtime or doesn't have STEAM_RUNTIME set; +- # default to enabled Steam Runtime in either case +- steam_runtime_path = os.path.join( +- steam_root, "ubuntu12_32", "steam-runtime") +- +- logger.info( +- "Using default Steam Runtime at %s", steam_runtime_path) +- return steam_runtime_path +- +- logger.error( +- "Path in STEAM_RUNTIME doesn't point to a valid Steam Runtime!") +- +- return None +- +- + APPINFO_STRUCT_HEADER = "<4sL" + APPINFO_STRUCT_SECTION = " Date: Sat, 12 Dec 2020 13:00:56 -0500 Subject: [PATCH 2/4] protontricks: 1.4.2 -> 1.4.3 --- .../protontricks/default.nix | 9 +- .../protontricks/steam-run.patch | 97 +++++++++++++------ 2 files changed, 77 insertions(+), 29 deletions(-) diff --git a/pkgs/tools/package-management/protontricks/default.nix b/pkgs/tools/package-management/protontricks/default.nix index 17bf1ba2f11..2c630933658 100644 --- a/pkgs/tools/package-management/protontricks/default.nix +++ b/pkgs/tools/package-management/protontricks/default.nix @@ -11,13 +11,13 @@ buildPythonApplication rec { pname = "protontricks"; - version = "1.4.2"; + version = "1.4.3"; src = fetchFromGitHub { owner = "Matoking"; repo = pname; rev = version; - sha256 = "0ri4phi1rna9snrxa6gl23walyack09mgax7zpjqfpxivwls3ach"; + sha256 = "0a5727igwafwvj8rr5lv0lx8rlfji3qkzmrbp0d15w5dc4fhknp0"; }; patches = [ @@ -44,6 +44,11 @@ buildPythonApplication rec { disabledTests = [ # Steam runtime is hard-coded with steam-run.patch and can't be configured "test_run_steam_runtime_not_found" + "test_unknown_steam_runtime_detected" + + # Steam runtime 2 currently isn't supported + # See https://github.com/NixOS/nixpkgs/issues/100655 + "test_run_winetricks_steam_runtime_v2" ]; meta = with lib; { diff --git a/pkgs/tools/package-management/protontricks/steam-run.patch b/pkgs/tools/package-management/protontricks/steam-run.patch index 0728213dc7d..536072cafc4 100644 --- a/pkgs/tools/package-management/protontricks/steam-run.patch +++ b/pkgs/tools/package-management/protontricks/steam-run.patch @@ -66,10 +66,10 @@ index 6506dae..2f762c9 100755 # escaping it cwd=steam_app.install_path, diff --git a/src/protontricks/steam.py b/src/protontricks/steam.py -index 0d3670e..d01cabe 100644 +index 215b31d..aa545b8 100644 --- a/src/protontricks/steam.py +++ b/src/protontricks/steam.py -@@ -12,7 +12,7 @@ from .util import lower_dict +@@ -11,7 +11,7 @@ from .util import lower_dict __all__ = ( "COMMON_STEAM_DIRS", "SteamApp", "find_steam_path", @@ -78,7 +78,7 @@ index 0d3670e..d01cabe 100644 "find_appid_proton_prefix", "get_steam_lib_paths", "get_steam_apps", "get_custom_proton_installations" ) -@@ -207,38 +207,6 @@ def find_steam_path(): +@@ -245,37 +245,6 @@ def find_steam_path(): return None, None @@ -93,19 +93,18 @@ index 0d3670e..d01cabe 100644 - # User has disabled Steam Runtime - logger.info("STEAM_RUNTIME is 0. Disabling Steam Runtime.") - return None -- elif os.path.isdir(env_steam_runtime): +- elif env_steam_runtime and Path(env_steam_runtime).is_dir(): - # User has a custom Steam Runtime - logger.info( - "Using custom Steam Runtime at %s", env_steam_runtime) -- return env_steam_runtime +- return Path(env_steam_runtime) - elif env_steam_runtime in ["1", ""]: - # User has enabled Steam Runtime or doesn't have STEAM_RUNTIME set; - # default to enabled Steam Runtime in either case -- steam_runtime_path = os.path.join( -- steam_root, "ubuntu12_32", "steam-runtime") +- steam_runtime_path = steam_root / "ubuntu12_32" / "steam-runtime" - - logger.info( -- "Using default Steam Runtime at %s", steam_runtime_path) +- "Using default Steam Runtime at %s", str(steam_runtime_path)) - return steam_runtime_path - - logger.error( @@ -118,36 +117,77 @@ index 0d3670e..d01cabe 100644 APPINFO_STRUCT_SECTION = " Date: Sun, 13 Dec 2020 10:11:45 -0500 Subject: [PATCH 3/4] winetricks: skip null dependencies This can be used to reduce closure size when a wrapper uses a custom WINE at runtime, or a different wine in PATH. See pkgs/tools/package-management/protontricks/default.nix --- pkgs/misc/emulators/wine/winetricks.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/misc/emulators/wine/winetricks.nix b/pkgs/misc/emulators/wine/winetricks.nix index ab183dfd38e..cfb35a9f996 100644 --- a/pkgs/misc/emulators/wine/winetricks.nix +++ b/pkgs/misc/emulators/wine/winetricks.nix @@ -10,7 +10,8 @@ stdenv.mkDerivation rec { # coreutils is for sha1sum pathAdd = stdenv.lib.concatMapStringsSep ":" (x: x + "/bin") - [ wine perl which coreutils zenity curl cabextract unzip p7zip gnused gnugrep bash ]; + (stdenv.lib.filter (x: x != null) + [ wine perl which coreutils zenity curl cabextract unzip p7zip gnused gnugrep bash ]); makeFlags = [ "PREFIX=$(out)" ]; From 57c9834f7d4f9dcad53175ab1abb1d7c0401de46 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Sun, 13 Dec 2020 10:13:36 -0500 Subject: [PATCH 4/4] protontricks: don't hard code default wine in winetricks Reduces closure size by 1.8G --- pkgs/tools/package-management/protontricks/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/package-management/protontricks/default.nix b/pkgs/tools/package-management/protontricks/default.nix index 2c630933658..e4e60442c8f 100644 --- a/pkgs/tools/package-management/protontricks/default.nix +++ b/pkgs/tools/package-management/protontricks/default.nix @@ -35,7 +35,11 @@ buildPythonApplication rec { makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ steam-run - winetricks + (winetricks.override { + # Remove default build of wine to reduce closure size. + # Falls back to wine in PATH when --no-runtime is passed. + wine = null; + }) zenity ]}" ];