6 extraPkgs ? pkgs: [ ], # extra packages to add to targetPkgs
7 extraLibraries ? pkgs: [ ], # extra packages to add to multiPkgs
8 extraProfile ? "", # string to append to profile
9 extraPreBwrapCmds ? "", # extra commands to run before calling bubblewrap
10 extraBwrapArgs ? [ ], # extra arguments to pass to bubblewrap (real default is at usage site)
11 extraArgs ? "", # arguments to always pass to steam
12 extraEnv ? { }, # Environment variables to pass to Steam
15 steamEnv = { name, runScript, passthru ? {}, meta ? {} }:
17 inherit name runScript passthru meta;
20 includeClosures = true;
22 # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#command-line-tools
23 targetPkgs = pkgs: with pkgs; [
29 lsb-release # not documented, called from Big Picture
30 pciutils # not documented, complains about lspci on startup
35 # Steam expects it to be /sbin specifically
36 (pkgs.runCommand "sbin-ldconfig" {} ''
38 ln -s /bin/ldconfig $out/sbin/ldconfig
41 # crashes on startup if it can't find libX11 locale files
42 (pkgs.runCommand "xorg-locale" {} ''
44 ln -s ${xorg.libX11}/share $out/share
48 # https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#shared-libraries
49 multiPkgs = pkgs: with pkgs; [
61 networkmanager # not documented, used for network status things in Big Picture
62 # FIXME: figure out how to only build libnm?
63 libcap # not documented, required by srt-bwrap
64 ] ++ extraLibraries pkgs;
66 extraInstallCommands = lib.optionalString (steam-unwrapped != null) ''
67 ln -s ${steam-unwrapped}/share $out/share
71 # prevents log spam from SteamRT GTK trying to load host GIO modules
72 unset GIO_EXTRA_MODULES
74 # udev event notifications don't work reliably inside containers.
75 # SDL2 already tries to automatically detect flatpak and pressure-vessel
76 # and falls back to inotify-based discovery [1]. We make SDL2 do the
77 # same by telling it explicitly.
79 # [1] <https://github.com/libsdl-org/SDL/commit/8e2746cfb6e1f1a1da5088241a1440fd2535e321>
80 export SDL_JOYSTICK_DISABLE_UDEV=1
82 # This is needed for IME (e.g. iBus, fcitx5) to function correctly on non-CJK locales
83 # https://github.com/ValveSoftware/steam-for-linux/issues/781#issuecomment-2004757379
84 export GTK_IM_MODULE='xim'
86 # See https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/distro-assumptions.md#graphics-driver
87 export LIBGL_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri
88 export __EGL_VENDOR_LIBRARY_DIRS=/run/opengl-driver/share/glvnd/egl_vendor.d:/run/opengl-driver-32/share/glvnd/egl_vendor.d
89 export LIBVA_DRIVERS_PATH=/run/opengl-driver/lib/dri:/run/opengl-driver-32/lib/dri
90 export VDPAU_DRIVER_PATH=/run/opengl-driver/lib/vdpau:/run/opengl-driver-32/lib/vdpau
93 ${lib.toShellVars extraEnv}
101 inherit extraPreBwrapCmds;
104 # Steam will dump crash reports here, make those more accessible
105 "--bind-try /tmp/dumps /tmp/dumps"
111 runScript = writeShellScript "steam-wrapped" ''
112 exec steam ${extraArgs} "$@"
115 passthru.run = steamEnv {
118 runScript = writeShellScript "steam-run" ''
119 if [ $# -eq 0 ]; then
120 echo "Usage: steam-run command-to-run args..." >&2
127 meta = (steam-unwrapped.meta or {}) // {
128 description = "Run commands in the same FHS environment that is used for Steam";
129 mainProgram = "steam-run";
131 # steam-run itself is just a script that lives in nixpkgs (which is licensed under MIT).
132 # steam is a dependency and already unfree, so normal steam-run will not install without
133 # allowing unfree packages or appropriate `allowUnfreePredicate` rules.
134 license = lib.licenses.mit;
138 meta = (steam-unwrapped.meta or {}) // {
139 description = "Steam dependencies (dummy package, do not use)";