lol

Merge pull request #213378 from Atemu/steam-env-vars

steam: add extraEnv argument

authored by

Atemu and committed by
GitHub
91f5aa34 2e0bb262

+49 -24
+26 -13
nixos/modules/programs/steam.nix
··· 9 enable = mkEnableOption (lib.mdDoc "steam"); 10 11 package = mkOption { 12 - type = types.package; 13 - default = pkgs.steam.override { 14 - extraLibraries = pkgs: with config.hardware.opengl; 15 - if pkgs.stdenv.hostPlatform.is64bit 16 - then [ package ] ++ extraPackages 17 - else [ package32 ] ++ extraPackages32; 18 - }; 19 - defaultText = literalExpression '' 20 - pkgs.steam.override { 21 - extraLibraries = pkgs: with config.hardware.opengl; 22 if pkgs.stdenv.hostPlatform.is64bit 23 then [ package ] ++ extraPackages 24 else [ package32 ] ++ extraPackages32; 25 - } 26 - ''; 27 description = lib.mdDoc '' 28 - steam package to use. 29 ''; 30 }; 31
··· 9 enable = mkEnableOption (lib.mdDoc "steam"); 10 11 package = mkOption { 12 + type = types.package; 13 + default = pkgs.steam; 14 + defaultText = literalExpression "pkgs.steam"; 15 + example = literalExpression '' 16 + pkgs.steam-small.override { 17 + extraEnv = { 18 + MANGOHUD = true; 19 + OBS_VKCAPTURE = true; 20 + RADV_TEX_ANISO = 16; 21 + }; 22 + extraLibraries = p: with p; [ 23 + atk 24 + ]; 25 + } 26 + ''; 27 + apply = steam: steam.override (prev: { 28 + extraLibraries = pkgs: let 29 + prevLibs = if prev ? extraLibraries then prev.extraLibraries pkgs else [ ]; 30 + additionalLibs = with config.hardware.opengl; 31 if pkgs.stdenv.hostPlatform.is64bit 32 then [ package ] ++ extraPackages 33 else [ package32 ] ++ extraPackages32; 34 + in prevLibs ++ additionalLibs; 35 + }); 36 description = lib.mdDoc '' 37 + The Steam package to use. Additional libraries are added from the system 38 + configuration to ensure graphics work properly. 39 + 40 + Use this option to customise the Steam package rather than adding your 41 + custom Steam to {option}`environment.systemPackages` yourself. 42 ''; 43 }; 44
+6 -5
pkgs/build-support/build-fhs-userenv-bubblewrap/default.nix
··· 20 21 with builtins; 22 let 23 - buildFHSEnv = callPackage ./env.nix { }; 24 25 - env = buildFHSEnv (removeAttrs args [ 26 "runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent" 27 "unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc" 28 "version" ··· 104 ro_mounts=() 105 symlinks=() 106 etc_ignored=() 107 - for i in ${env}/*; do 108 path="/''${i##*/}" 109 if [[ $path == '/etc' ]]; then 110 : ··· 117 fi 118 done 119 120 - if [[ -d ${env}/etc ]]; then 121 - for i in ${env}/etc/*; do 122 path="/''${i##*/}" 123 # NOTE: we're binding /etc/fonts and /etc/ssl/certs from the host so we 124 # don't want to override it with a path from the FHS environment. ··· 221 echo >&2 "" 222 exit 1 223 ''; 224 }; 225 } '' 226 mkdir -p $out/bin
··· 20 21 with builtins; 22 let 23 + buildFHSEnv = callPackage ./buildFHSEnv.nix { }; 24 25 + fhsenv = buildFHSEnv (removeAttrs args [ 26 "runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent" 27 "unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc" 28 "version" ··· 104 ro_mounts=() 105 symlinks=() 106 etc_ignored=() 107 + for i in ${fhsenv}/*; do 108 path="/''${i##*/}" 109 if [[ $path == '/etc' ]]; then 110 : ··· 117 fi 118 done 119 120 + if [[ -d ${fhsenv}/etc ]]; then 121 + for i in ${fhsenv}/etc/*; do 122 path="/''${i##*/}" 123 # NOTE: we're binding /etc/fonts and /etc/ssl/certs from the host so we 124 # don't want to override it with a path from the FHS environment. ··· 221 echo >&2 "" 222 exit 1 223 ''; 224 + inherit args fhsenv; 225 }; 226 } '' 227 mkdir -p $out/bin
+5 -1
pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix pkgs/build-support/build-fhs-userenv-bubblewrap/buildFHSEnv.nix
··· 1 { stdenv, lib, buildEnv, writeText, writeShellScriptBin, pkgs, pkgsi686Linux }: 2 3 - { name, profile ? "" 4 , targetPkgs ? pkgs: [], multiPkgs ? pkgs: [] 5 , extraBuildCommands ? "", extraBuildCommandsMulti ? "" 6 , extraOutputsToInstall ? [] ··· 216 ''; 217 preferLocalBuild = true; 218 allowSubstitutes = false; 219 }
··· 1 { stdenv, lib, buildEnv, writeText, writeShellScriptBin, pkgs, pkgsi686Linux }: 2 3 + args@{ name, profile ? "" 4 , targetPkgs ? pkgs: [], multiPkgs ? pkgs: [] 5 , extraBuildCommands ? "", extraBuildCommandsMulti ? "" 6 , extraOutputsToInstall ? [] ··· 216 ''; 217 preferLocalBuild = true; 218 allowSubstitutes = false; 219 + 220 + passthru = { 221 + inherit args multiPaths targetPaths; 222 + }; 223 }
+12 -5
pkgs/games/steam/fhsenv.nix
··· 1 - { lib, stdenv, writeScript, buildFHSUserEnv, steam, glxinfo-i686, runtimeShell 2 , steam-runtime-wrapped, steam-runtime-wrapped-i686 ? null 3 , extraPkgs ? pkgs: [ ] # extra packages to add to targetPkgs 4 , extraLibraries ? pkgs: [ ] # extra packages to add to multiPkgs 5 , extraProfile ? "" # string to append to profile 6 , extraArgs ? "" # arguments to always pass to steam 7 , withGameSpecificLibraries ? true # exclude game specific libraries 8 }: 9 ··· 51 chmod +w $HOME/.local/share/Steam/bootstrap.tar.xz 52 fi 53 ''; 54 55 in buildFHSUserEnv rec { 56 name = "steam"; ··· 228 export SDL_JOYSTICK_DISABLE_UDEV=1 229 '' + extraProfile; 230 231 - runScript = writeScript "steam-wrapper.sh" '' 232 - #!${runtimeShell} 233 if [ -f /host/etc/NIXOS ]; then # Check only useful on NixOS 234 ${glxinfo-i686}/bin/glxinfo >/dev/null 2>&1 235 # If there was an error running glxinfo, we know something is wrong with the configuration ··· 249 250 ${exportLDPath} 251 ${fixBootstrap} 252 exec steam ${extraArgs} "$@" 253 ''; 254 ··· 272 inherit multiPkgs profile extraInstallCommands; 273 inherit unshareIpc unsharePid; 274 275 - runScript = writeScript "steam-run" '' 276 - #!${runtimeShell} 277 run="$1" 278 if [ "$run" = "" ]; then 279 echo "Usage: steam-run command-to-run args..." >&2 ··· 283 284 ${exportLDPath} 285 ${fixBootstrap} 286 exec -- "$run" "$@" 287 ''; 288
··· 1 + { lib, stdenv, writeShellScript, buildFHSUserEnv, steam, glxinfo-i686 2 , steam-runtime-wrapped, steam-runtime-wrapped-i686 ? null 3 , extraPkgs ? pkgs: [ ] # extra packages to add to targetPkgs 4 , extraLibraries ? pkgs: [ ] # extra packages to add to multiPkgs 5 , extraProfile ? "" # string to append to profile 6 , extraArgs ? "" # arguments to always pass to steam 7 + , extraEnv ? { } # Environment variables to pass to Steam 8 , withGameSpecificLibraries ? true # exclude game specific libraries 9 }: 10 ··· 52 chmod +w $HOME/.local/share/Steam/bootstrap.tar.xz 53 fi 54 ''; 55 + 56 + envScript = lib.toShellVars extraEnv; 57 58 in buildFHSUserEnv rec { 59 name = "steam"; ··· 231 export SDL_JOYSTICK_DISABLE_UDEV=1 232 '' + extraProfile; 233 234 + runScript = writeShellScript "steam-wrapper.sh" '' 235 if [ -f /host/etc/NIXOS ]; then # Check only useful on NixOS 236 ${glxinfo-i686}/bin/glxinfo >/dev/null 2>&1 237 # If there was an error running glxinfo, we know something is wrong with the configuration ··· 251 252 ${exportLDPath} 253 ${fixBootstrap} 254 + 255 + set -o allexport # Export the following env vars 256 + ${envScript} 257 exec steam ${extraArgs} "$@" 258 ''; 259 ··· 277 inherit multiPkgs profile extraInstallCommands; 278 inherit unshareIpc unsharePid; 279 280 + runScript = writeShellScript "steam-run" '' 281 run="$1" 282 if [ "$run" = "" ]; then 283 echo "Usage: steam-run command-to-run args..." >&2 ··· 287 288 ${exportLDPath} 289 ${fixBootstrap} 290 + 291 + set -o allexport # Export the following env vars 292 + ${envScript} 293 exec -- "$run" "$@" 294 ''; 295