diff --git a/pkgs/by-name/st/steam/package.nix b/pkgs/by-name/st/steam/package.nix index 57af5f00af64..06c08f7490ef 100644 --- a/pkgs/by-name/st/steam/package.nix +++ b/pkgs/by-name/st/steam/package.nix @@ -13,161 +13,191 @@ privateTmp ? true, # if the steam bubblewrap should isolate /tmp }: let - steamEnv = + buildRuntimeEnv = { - name, - runScript, - passthru ? { }, - meta ? { }, - }: - buildFHSEnv { - inherit - name - runScript - passthru - meta - privateTmp - ; + extraPkgs ? pkgs: [ ], + extraLibraries ? pkgs: [ ], + extraProfile ? "", + extraPreBwrapCmds ? "", + extraBwrapArgs ? [ ], + extraEnv ? { }, + ... + }@args: + buildFHSEnv ( + (builtins.removeAttrs args [ + "extraPkgs" + "extraLibraries" + "extraProfile" + "extraPreBwrapCmds" + "extraBwrapArgs" + "extraArgs" + "extraEnv" + ]) + // { + inherit privateTmp; - multiArch = true; - includeClosures = true; + multiArch = true; + includeClosures = true; - # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#command-line-tools - targetPkgs = - pkgs: - with pkgs; - [ - steam-unwrapped + # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#command-line-tools + targetPkgs = + pkgs: + with pkgs; + [ + bash + coreutils + file + lsb-release # not documented, called from Big Picture + pciutils # not documented, complains about lspci on startup + glibc_multi.bin + xdg-utils # calls xdg-open occasionally + xz + zenity - bash - coreutils - file - lsb-release # not documented, called from Big Picture - pciutils # not documented, complains about lspci on startup - glibc_multi.bin - xdg-utils # calls xdg-open occasionally - xz - zenity + # Steam expects it to be /sbin specifically + (pkgs.runCommand "sbin-ldconfig" { } '' + mkdir -p $out/sbin + ln -s /bin/ldconfig $out/sbin/ldconfig + '') - # Steam expects it to be /sbin specifically - (pkgs.runCommand "sbin-ldconfig" { } '' - mkdir -p $out/sbin - ln -s /bin/ldconfig $out/sbin/ldconfig - '') + # crashes on startup if it can't find libX11 locale files + (pkgs.runCommand "xorg-locale" { } '' + mkdir -p $out + ln -s ${xorg.libX11}/share $out/share + '') + ] + ++ extraPkgs pkgs; - # crashes on startup if it can't find libX11 locale files - (pkgs.runCommand "xorg-locale" { } '' - mkdir -p $out - ln -s ${xorg.libX11}/share $out/share - '') - ] - ++ extraPkgs pkgs; + # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#shared-libraries + multiPkgs = + pkgs: + with pkgs; + [ + glibc + libxcrypt + libGL - # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#shared-libraries - multiPkgs = - pkgs: - with pkgs; - [ - glibc - libxcrypt - libGL + libdrm + libgbm + udev + libudev0-shim + libva + vulkan-loader - libdrm - libgbm - udev - libudev0-shim - libva - vulkan-loader + networkmanager + # not documented, used for network status things in Big Picture + # FIXME: figure out how to only build libnm? + libcap # not documented, required by srt-bwrap + ] + ++ extraLibraries pkgs; - networkmanager - # not documented, used for network status things in Big Picture - # FIXME: figure out how to only build libnm? - libcap # not documented, required by srt-bwrap - ] - ++ extraLibraries pkgs; + profile = '' + # prevents log spam from SteamRT GTK trying to load host GIO modules + unset GIO_EXTRA_MODULES - extraInstallCommands = lib.optionalString (steam-unwrapped != null) '' - ln -s ${steam-unwrapped}/share $out/share - ''; + # udev event notifications don't work reliably inside containers. + # SDL2 already tries to automatically detect flatpak and pressure-vessel + # and falls back to inotify-based discovery [1]. We make SDL2 do the + # same by telling it explicitly. + # + # [1] + export SDL_JOYSTICK_DISABLE_UDEV=1 - profile = '' - # prevents log spam from SteamRT GTK trying to load host GIO modules - unset GIO_EXTRA_MODULES + # This is needed for IME (e.g. iBus, fcitx5) to function correctly on non-CJK locales + # https://github.com/ValveSoftware/steam-for-linux/issues/781#issuecomment-2004757379 + export GTK_IM_MODULE='xim' - # udev event notifications don't work reliably inside containers. - # SDL2 already tries to automatically detect flatpak and pressure-vessel - # and falls back to inotify-based discovery [1]. We make SDL2 do the - # same by telling it explicitly. - # - # [1] - export SDL_JOYSTICK_DISABLE_UDEV=1 + # See https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#graphics-driver + export LIBGL_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri + export __EGL_VENDOR_LIBRARY_DIRS=/run/opengl-driver/share/glvnd/egl_vendor.d:/run/opengl-driver-32/share/glvnd/egl_vendor.d + export LIBVA_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri + export VDPAU_DRIVER_PATH=/run/opengl-driver/lib/vdpau:/run/opengl-driver-32/lib/vdpau - # This is needed for IME (e.g. iBus, fcitx5) to function correctly on non-CJK locales - # https://github.com/ValveSoftware/steam-for-linux/issues/781#issuecomment-2004757379 - export GTK_IM_MODULE='xim' - - # See https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#graphics-driver - export LIBGL_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri - export __EGL_VENDOR_LIBRARY_DIRS=/run/opengl-driver/share/glvnd/egl_vendor.d:/run/opengl-driver-32/share/glvnd/egl_vendor.d - export LIBVA_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri - export VDPAU_DRIVER_PATH=/run/opengl-driver/lib/vdpau:/run/opengl-driver-32/lib/vdpau - - # Steam gets confused by the symlinks to bind mounts to symlinks /etc/localtime ends up being, so help it out. - # See also: https://github.com/flathub/com.valvesoftware.Steam/blob/28481f09f33c12b6ac7421d13af9ed1523c54ec4/steam_wrapper/steam_wrapper.py#L160 - if [ -z ''${TZ+x} ]; then - new_TZ="$(readlink -f /etc/localtime | grep -P -o '(?<=/zoneinfo/).*$')" - if [ $? -eq 0 ]; then - export TZ="$new_TZ" + # Steam gets confused by the symlinks to bind mounts to symlinks /etc/localtime ends up being, so help it out. + # See also: https://github.com/flathub/com.valvesoftware.Steam/blob/28481f09f33c12b6ac7421d13af9ed1523c54ec4/steam_wrapper/steam_wrapper.py#L160 + if [ -z ''${TZ+x} ]; then + new_TZ="$(readlink -f /etc/localtime | grep -P -o '(?<=/zoneinfo/).*$')" + if [ $? -eq 0 ]; then + export TZ="$new_TZ" + fi fi - fi - set -a - ${lib.toShellVars extraEnv} - set +a + set -a + ${lib.toShellVars extraEnv} + set +a - ${extraProfile} - ''; + ${extraProfile} + ''; - inherit extraPreBwrapCmds; + inherit extraPreBwrapCmds; - extraBwrapArgs = [ - # Steam will dump crash reports here, make those more accessible - "--bind-try /tmp/dumps /tmp/dumps" - ] - ++ extraBwrapArgs; - }; + extraBwrapArgs = [ + # Steam will dump crash reports here, make those more accessible + "--bind-try /tmp/dumps /tmp/dumps" + ] + ++ extraBwrapArgs; + } + ); in -steamEnv { - name = "steam"; +buildRuntimeEnv { + pname = "steam"; + inherit (steam-unwrapped) version meta; + + extraPkgs = pkgs: [ steam-unwrapped ] ++ extraPkgs pkgs; + inherit + extraLibraries + extraProfile + extraPreBwrapCmds + extraBwrapArgs + extraEnv + ; runScript = writeShellScript "steam-wrapped" '' exec steam ${extraArgs} "$@" ''; - passthru.run = steamEnv { - name = "steam-run"; + extraInstallCommands = '' + ln -s ${steam-unwrapped}/share $out/share + ''; - runScript = writeShellScript "steam-run" '' - if [ $# -eq 0 ]; then - echo "Usage: steam-run command-to-run args..." >&2 - exit 1 - fi + passthru = + let + makeSteamRun = + package: + buildRuntimeEnv { + name = "steam-run"; - exec "$@" - ''; + extraPkgs = pkgs: package ++ extraPkgs pkgs; - meta = (steam-unwrapped.meta or { }) // { - description = "Run commands in the same FHS environment that is used for Steam"; - mainProgram = "steam-run"; - name = "steam-run"; - # steam-run itself is just a script that lives in nixpkgs (which is licensed under MIT). - # steam is a dependency and already unfree, so normal steam-run will not install without - # allowing unfree packages or appropriate `allowUnfreePredicate` rules. - license = lib.licenses.mit; + inherit + extraLibraries + extraProfile + extraPreBwrapCmds + extraBwrapArgs + extraEnv + ; + + runScript = writeShellScript "steam-run" '' + if [ $# -eq 0 ]; then + echo "Usage: steam-run command-to-run args..." >&2 + exit 1 + fi + + exec "$@" + ''; + + meta = { + description = "Run commands in the same FHS environment that is used for Steam"; + mainProgram = "steam-run"; + name = "steam-run"; + license = lib.licenses.mit; + }; + }; + in + { + inherit buildRuntimeEnv; + + run = makeSteamRun [ steam-unwrapped ]; + run-free = makeSteamRun [ ]; }; - }; - - meta = (steam-unwrapped.meta or { }) // { - description = "Steam dependencies (dummy package, do not use)"; - }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index affa0ae81764..6a374f0ce565 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14922,11 +14922,7 @@ with pkgs; springLobby = callPackage ../games/spring/springlobby.nix { }; steam-run = steam.run; - - # This exists so Hydra tries to build all of Steam's dependencies. - steam-fhsenv-without-steam = steam.override { steam-unwrapped = null; }; - - steam-run-free = steam-fhsenv-without-steam.run; + steam-run-free = steam.run-free; steamback = python3.pkgs.callPackage ../tools/games/steamback { };