Merge pull request #213378 from Atemu/steam-env-vars
steam: add extraEnv argument
This commit is contained in:
commit
91f5aa3446
4 changed files with 49 additions and 24 deletions
|
@ -9,23 +9,36 @@ in {
|
||||||
enable = mkEnableOption (lib.mdDoc "steam");
|
enable = mkEnableOption (lib.mdDoc "steam");
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.steam.override {
|
default = pkgs.steam;
|
||||||
extraLibraries = pkgs: with config.hardware.opengl;
|
defaultText = literalExpression "pkgs.steam";
|
||||||
if pkgs.stdenv.hostPlatform.is64bit
|
example = literalExpression ''
|
||||||
then [ package ] ++ extraPackages
|
pkgs.steam-small.override {
|
||||||
else [ package32 ] ++ extraPackages32;
|
extraEnv = {
|
||||||
};
|
MANGOHUD = true;
|
||||||
defaultText = literalExpression ''
|
OBS_VKCAPTURE = true;
|
||||||
pkgs.steam.override {
|
RADV_TEX_ANISO = 16;
|
||||||
extraLibraries = pkgs: with config.hardware.opengl;
|
};
|
||||||
|
extraLibraries = p: with p; [
|
||||||
|
atk
|
||||||
|
];
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
apply = steam: steam.override (prev: {
|
||||||
|
extraLibraries = pkgs: let
|
||||||
|
prevLibs = if prev ? extraLibraries then prev.extraLibraries pkgs else [ ];
|
||||||
|
additionalLibs = with config.hardware.opengl;
|
||||||
if pkgs.stdenv.hostPlatform.is64bit
|
if pkgs.stdenv.hostPlatform.is64bit
|
||||||
then [ package ] ++ extraPackages
|
then [ package ] ++ extraPackages
|
||||||
else [ package32 ] ++ extraPackages32;
|
else [ package32 ] ++ extraPackages32;
|
||||||
}
|
in prevLibs ++ additionalLibs;
|
||||||
'';
|
});
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
steam package to use.
|
The Steam package to use. Additional libraries are added from the system
|
||||||
|
configuration to ensure graphics work properly.
|
||||||
|
|
||||||
|
Use this option to customise the Steam package rather than adding your
|
||||||
|
custom Steam to {option}`environment.systemPackages` yourself.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ stdenv, lib, buildEnv, writeText, writeShellScriptBin, pkgs, pkgsi686Linux }:
|
{ stdenv, lib, buildEnv, writeText, writeShellScriptBin, pkgs, pkgsi686Linux }:
|
||||||
|
|
||||||
{ name, profile ? ""
|
args@{ name, profile ? ""
|
||||||
, targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
|
, targetPkgs ? pkgs: [], multiPkgs ? pkgs: []
|
||||||
, extraBuildCommands ? "", extraBuildCommandsMulti ? ""
|
, extraBuildCommands ? "", extraBuildCommandsMulti ? ""
|
||||||
, extraOutputsToInstall ? []
|
, extraOutputsToInstall ? []
|
||||||
|
@ -216,4 +216,8 @@ in stdenv.mkDerivation {
|
||||||
'';
|
'';
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
allowSubstitutes = false;
|
allowSubstitutes = false;
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
inherit args multiPaths targetPaths;
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -20,9 +20,9 @@ args @ {
|
||||||
|
|
||||||
with builtins;
|
with builtins;
|
||||||
let
|
let
|
||||||
buildFHSEnv = callPackage ./env.nix { };
|
buildFHSEnv = callPackage ./buildFHSEnv.nix { };
|
||||||
|
|
||||||
env = buildFHSEnv (removeAttrs args [
|
fhsenv = buildFHSEnv (removeAttrs args [
|
||||||
"runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent"
|
"runScript" "extraInstallCommands" "meta" "passthru" "extraBwrapArgs" "dieWithParent"
|
||||||
"unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
|
"unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
|
||||||
"version"
|
"version"
|
||||||
|
@ -104,7 +104,7 @@ let
|
||||||
ro_mounts=()
|
ro_mounts=()
|
||||||
symlinks=()
|
symlinks=()
|
||||||
etc_ignored=()
|
etc_ignored=()
|
||||||
for i in ${env}/*; do
|
for i in ${fhsenv}/*; do
|
||||||
path="/''${i##*/}"
|
path="/''${i##*/}"
|
||||||
if [[ $path == '/etc' ]]; then
|
if [[ $path == '/etc' ]]; then
|
||||||
:
|
:
|
||||||
|
@ -117,8 +117,8 @@ let
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -d ${env}/etc ]]; then
|
if [[ -d ${fhsenv}/etc ]]; then
|
||||||
for i in ${env}/etc/*; do
|
for i in ${fhsenv}/etc/*; do
|
||||||
path="/''${i##*/}"
|
path="/''${i##*/}"
|
||||||
# NOTE: we're binding /etc/fonts and /etc/ssl/certs from the host so we
|
# NOTE: we're binding /etc/fonts and /etc/ssl/certs from the host so we
|
||||||
# don't want to override it with a path from the FHS environment.
|
# don't want to override it with a path from the FHS environment.
|
||||||
|
@ -221,6 +221,7 @@ in runCommandLocal nameAndVersion {
|
||||||
echo >&2 ""
|
echo >&2 ""
|
||||||
exit 1
|
exit 1
|
||||||
'';
|
'';
|
||||||
|
inherit args fhsenv;
|
||||||
};
|
};
|
||||||
} ''
|
} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{ lib, stdenv, writeScript, buildFHSUserEnv, steam, glxinfo-i686, runtimeShell
|
{ lib, stdenv, writeShellScript, buildFHSUserEnv, steam, glxinfo-i686
|
||||||
, steam-runtime-wrapped, steam-runtime-wrapped-i686 ? null
|
, steam-runtime-wrapped, steam-runtime-wrapped-i686 ? null
|
||||||
, extraPkgs ? pkgs: [ ] # extra packages to add to targetPkgs
|
, extraPkgs ? pkgs: [ ] # extra packages to add to targetPkgs
|
||||||
, extraLibraries ? pkgs: [ ] # extra packages to add to multiPkgs
|
, extraLibraries ? pkgs: [ ] # extra packages to add to multiPkgs
|
||||||
, extraProfile ? "" # string to append to profile
|
, extraProfile ? "" # string to append to profile
|
||||||
, extraArgs ? "" # arguments to always pass to steam
|
, extraArgs ? "" # arguments to always pass to steam
|
||||||
|
, extraEnv ? { } # Environment variables to pass to Steam
|
||||||
, withGameSpecificLibraries ? true # exclude game specific libraries
|
, withGameSpecificLibraries ? true # exclude game specific libraries
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ let
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
envScript = lib.toShellVars extraEnv;
|
||||||
|
|
||||||
in buildFHSUserEnv rec {
|
in buildFHSUserEnv rec {
|
||||||
name = "steam";
|
name = "steam";
|
||||||
|
|
||||||
|
@ -228,8 +231,7 @@ in buildFHSUserEnv rec {
|
||||||
export SDL_JOYSTICK_DISABLE_UDEV=1
|
export SDL_JOYSTICK_DISABLE_UDEV=1
|
||||||
'' + extraProfile;
|
'' + extraProfile;
|
||||||
|
|
||||||
runScript = writeScript "steam-wrapper.sh" ''
|
runScript = writeShellScript "steam-wrapper.sh" ''
|
||||||
#!${runtimeShell}
|
|
||||||
if [ -f /host/etc/NIXOS ]; then # Check only useful on NixOS
|
if [ -f /host/etc/NIXOS ]; then # Check only useful on NixOS
|
||||||
${glxinfo-i686}/bin/glxinfo >/dev/null 2>&1
|
${glxinfo-i686}/bin/glxinfo >/dev/null 2>&1
|
||||||
# If there was an error running glxinfo, we know something is wrong with the configuration
|
# If there was an error running glxinfo, we know something is wrong with the configuration
|
||||||
|
@ -249,6 +251,9 @@ in buildFHSUserEnv rec {
|
||||||
|
|
||||||
${exportLDPath}
|
${exportLDPath}
|
||||||
${fixBootstrap}
|
${fixBootstrap}
|
||||||
|
|
||||||
|
set -o allexport # Export the following env vars
|
||||||
|
${envScript}
|
||||||
exec steam ${extraArgs} "$@"
|
exec steam ${extraArgs} "$@"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -272,8 +277,7 @@ in buildFHSUserEnv rec {
|
||||||
inherit multiPkgs profile extraInstallCommands;
|
inherit multiPkgs profile extraInstallCommands;
|
||||||
inherit unshareIpc unsharePid;
|
inherit unshareIpc unsharePid;
|
||||||
|
|
||||||
runScript = writeScript "steam-run" ''
|
runScript = writeShellScript "steam-run" ''
|
||||||
#!${runtimeShell}
|
|
||||||
run="$1"
|
run="$1"
|
||||||
if [ "$run" = "" ]; then
|
if [ "$run" = "" ]; then
|
||||||
echo "Usage: steam-run command-to-run args..." >&2
|
echo "Usage: steam-run command-to-run args..." >&2
|
||||||
|
@ -283,6 +287,9 @@ in buildFHSUserEnv rec {
|
||||||
|
|
||||||
${exportLDPath}
|
${exportLDPath}
|
||||||
${fixBootstrap}
|
${fixBootstrap}
|
||||||
|
|
||||||
|
set -o allexport # Export the following env vars
|
||||||
|
${envScript}
|
||||||
exec -- "$run" "$@"
|
exec -- "$run" "$@"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue