Difference between revisions of "Steam"

From NixOS Wiki
Jump to: navigation, search
(Adds a quick note about steam-run)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(58 intermediate revisions by 39 users not shown)
Line 1: Line 1:
 +
{{Expansion|See notes in ->}}
  
This page is intended to describe the current state of Steam under NixOS.
+
This page is intended to explain how to run Steam, Steam games as well as proprietary DRM-free games under NixOS. A dedicated [[Games]] page lists games and reports on their successful execution on NixOS.  
  
== I want to play ==
+
== Install ==
For 64-bit systems it's important to have <syntaxhighlight lang="nix" inline>hardware.opengl.driSupport32Bit = true</syntaxhighlight> in your NixOS configuration. You'll also need <syntaxhighlight lang="nix" inline>hardware.pulseaudio.support32Bit = true</syntaxhighlight> if you are using PulseAudio - this will enable 32bit ALSA apps integration.
 
  
In short, add this to your <code>configuration.nix</code>
+
To install the Steam package and enable all the system options necessary to allow it to run:
 +
 
 +
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 +
programs.steam = {
 +
  enable = true;
 +
  remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
 +
  dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
 +
};
 +
</nowiki>}}
 +
 
 +
{{note|Enabling steam installs several unfree packages. If you are using <code>allowUnfreePredicate</code> you will need to ensure that your configurations permit all of them.
 
<syntaxHighlight lang=nix>
 
<syntaxHighlight lang=nix>
 
{
 
{
   ...
+
   nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
  users.users.<your-username>.packages = [
+
    "steam"
     pkgs.steam
+
    "steam-original"
 +
     "steam-run"
 
   ];
 
   ];
  hardware.opengl.driSupport32Bit = true;
 
  hardware.pulseaudio.support32Bit = true;
 
 
}
 
}
 
</syntaxHighlight>
 
</syntaxHighlight>
 +
}}
 +
 +
 +
 +
=== steam-tui ===
 +
If you want the steam-tui client you'll have to install it, but since it relies on `steamcmd` being set up, you'll have to set that up, just to generate the right files.
 +
<syntaxHighlight lang=nix>
 +
nix-shell -p steamcmd --run steamcmd
 +
</syntaxHighlight>
 +
And then log in: <syntaxHighlight>login <username> <password> <steam 2fa password></syntaxHighlight>
 +
After that, steam-tui should start fine.
 +
 +
=== FHS environment only ===
 +
This will only make partial installation - provide the script, which creates the typical environment expected by proprietary games and software on regular Linux, allowing to run such software without patching. Useful if you plan to run games downloaded from the internet.
 +
 +
Note that this is not necessary for clients installed from Nixpkgs (like Minigalaxy or Itch), which already use the FHS environment.
 +
 +
There are two options to install the FHS environment. The first is to install <syntaxhighlight lang="nix" inline>steam-run</syntaxhighlight>.
 +
 +
Example snippet of <code>configuration.nix</code>:
 +
<syntaxHighlight lang=nix>
 +
  environment.systemPackages = with pkgs; [
 +
    steam-run
 +
  ];
 +
</syntaxHighlight>
 +
 +
Another option, in case you need more flexibility, is to directly reference the part of steam metapackage.
 +
 +
Example snippet of <code>configuration.nix</code>:
 +
<syntaxHighlight lang=nix>
 +
  environment.systemPackages = with pkgs; [
 +
    (steam.override { /* Your overrides here */ }).run
 +
  ];
 +
</syntaxHighlight>
 +
 +
Install the game by setting the executable attribute on the installer and then running it via <code>steam-run ./your_installer.sh</code>. After installation, edit the "~/.local/share/applications/your_game.desktop" and replace the exec line from <code>Exec="/home/user/game/start.sh" ""</code> with <code>Exec="steam-run" "/home/user/game/start.sh"</code>.
 +
 +
== Adding missing dependencies ==
 +
 +
In some cases, you may need to override steam to provide missing dependencies.
 +
Use the <code>programs.steam.package</code> for this.
 +
 +
=== Bumblebee and Primus ===
 +
<syntaxHighlight lang=nix>
 +
  programs.steam.package = pkgs.steam.override {
 +
    withPrimus = true;
 +
    extraPkgs = pkgs: [ bumblebee glxinfo ];
 +
  };
 +
</syntaxHighlight>
 +
 +
=== Java ===
 +
<syntaxHighlight lang=nix>
 +
  programs.java.enable = true;
 +
  programs.steam.package = pkgs.steam.override { withJava = true; };
 +
</syntaxHighlight>
 +
 +
== gamescope ==
 +
 +
To use the [https://github.com/ValveSoftware/gamescope gamescope] compositor, which enables features such as resolution upscaling and stretched aspect ratios (such as 4:3), set
  
{{tip|Install "steam" package. Run "steam". Many of the games will just work.}}
+
<syntaxHighlight lang=nix>
 +
programs.steam.gamescopeSession.enable = true;
 +
</syntaxHighlight>
 +
 
 +
in your system configuration.
  
 
== Troubleshooting ==
 
== Troubleshooting ==
I was sure you would reach this part.
+
 
 +
For all issues: first run steam through the terminal and read the output.
  
 
=== Steam fails to start. What do I do? ===
 
=== Steam fails to start. What do I do? ===
strace is your friend.
+
<code>strace</code> then open a bug report.
 +
 
 +
=== Steam is not updated ===
 +
 
 +
When you restart Steam after an update, it starts the old version. ([https://github.com/NixOS/nixpkgs/issues/181904 #181904])
 +
 
 +
A '''workaround''' is to remove the user files in <code>/home/<user>/.local/share/Steam</code> and setup Steam again.
  
=== Game X fails to start ===
+
=== Game fails to start ===
 
Games may fail to start because they lack dependencies (this should be added to the script, for now), or because they cannot be patched. The steps to launch a game directly are:
 
Games may fail to start because they lack dependencies (this should be added to the script, for now), or because they cannot be patched. The steps to launch a game directly are:
 
* Patch the script/binary if you can
 
* Patch the script/binary if you can
Line 31: Line 110:
 
* Using the LD_LIBRARY_PATH from the nix/store steam script, with some additions, launch the game binary
 
* Using the LD_LIBRARY_PATH from the nix/store steam script, with some additions, launch the game binary
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
  LD_LIBRARY_PATH=~/.steam/bin32:$LD_LIBRARY_PATH:/nix/store/pfsa... blabla ...curl-7.29.0/lib:. ./Osmos.bin32 (if you could not patchelf the game, call ld.so directly with the binary as param)
+
  LD_LIBRARY_PATH=~/.steam/bin32:$LD_LIBRARY_PATH:/nix/store/pfsa... blabla ...curl-7.29.0/lib:. ./Osmos.bin32 (if you could not patchelf the game, call ld.so directly with the binary as parameter)
 
</syntaxhighlight>
 
</syntaxhighlight>
With this technique, I can play many games directly from steam. Others, like Team Fortress, cannot be patched so I only managed to run them from the cmd line.
 
  
=== new Libcpp for steam ===
+
Note: If a game gets stuck on Installing scripts, check for a DXSETUP.EXE process and run it manually, then restart the game launch.
{{outdated|Since the merge of {{issue|29180}} this subsection is obsolete}}
+
 
The open source radeon drivers need a newer libc++ than is provided by the default runtime, which leads to acrash on launch. Use
+
==== Changing the driver on AMD GPUs ====
<syntaxhighlight lang="nix">
+
 
(steamPackages.override { newLibcpp = true; }).steam-chrootenv
+
Sometimes, changing the driver on AMD GPUs helps. To try this, first, install multiple drivers such as radv and amdvlk:
</syntaxhighlight>
+
 
[https://github.com/NixOS/nixpkgs/pull/12404 in your config] if you get an error like
+
<syntaxHighlight lang=nix>
 +
hardware.opengl = {
 +
  ## radv: an open-source Vulkan driver from freedesktop
 +
  driSupport = true;
 +
  driSupport32Bit = true;
 +
 
 +
  ## amdvlk: an open-source Vulkan driver from AMD
 +
  extraPackages = [ pkgs.amdvlk ];
 +
  extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
 +
};
 +
</syntaxHighlight>
 +
 
 +
In the presence of both drivers, Steam will default to amdvlk. The amdvlk driver can be considered more correct regarding Vulkan specification implementation, but less performant than radv. However, this tradeoff between correctness and performance can sometimes make or break the gaming experience.
 +
 
 +
To "reset" your driver to radv when both radv and amdvlk are installed, set either <code>AMD_VULKAN_ICD = "RADV"</code> or <code>VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json"</code> environment variable. For example, if you start Steam from the shell, you can enable radv for the current session by running <code>AMD_VULKAN_ICD="RADV" steam</code>. If you are unsure which driver you currently use, you can launch a game with [https://github.com/flightlessmango/MangoHud MangoHud] enabled, which has the capability to show what driver is currently in use.
 +
 
 +
=== SteamVR ===
 +
 
 +
The setcap issue at SteamVR start can be fixed with:
  
libGL error: unable to load driver: radeonsi_dri.so
+
<code>sudo setcap CAP_SYS_NICE+ep ~/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher</code>
libGL error: driver pointer missing
 
libGL error: failed to load driver: radeonsi
 
libGL error: unable to load driver: swrast_dri.so
 
libGL error: failed to load driver: swrast
 
  
 
=== Known issues ===
 
=== Known issues ===
# No java in steam chrootenv. Games affected: Towns:
+
"Project Zomboid" may report "couldn't determine 32/64 bit of java". This is not related to java at all, it carries its own outdated java binary that refuses to start if path contains non-Latin characters. Check for errors by directly starting local java binary within <code>steam-run bash</code>.
<syntaxhighlight lang="console">
+
 
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found
+
Resetting your password through the Steam app may fail at the CAPTCHA step repeatedly, with Steam itself reporting that the CAPTCHA was not correct, even though the CAPTCHA UI shows success. Resetting password through the Steam website should work around that.
</syntaxhighlight>
+
 
 +
== Steam hardware ==
 +
If you are using a Steam Controller or a Valve Index, you will want to add <code>hardware.steam-hardware.enable = true;</code> to your configuration.
 +
 
 +
Note that this is already enabled with <code>programs.steam.enable = true;</code>.
 +
 
 +
[[Category:Applications]]
 +
 
 +
== Proton ==
 +
 
 +
=== NixOS 21.11 ===
  
=== HiDPI ===
+
From this version of NixOS onwards, you should be able to play most games with Proton.
If you're blessed with a higher DPI monitor, Steam's UI fonts may be unbearably tiny. You can add a custom skin from https://github.com/MoriTanosuke/HiDPI-Steam-Skin for your user to alleviate this. The skins directory is ~/.local/share/Steam/skins/.
 
  
== steam-run ==
+
=== Custom Proton versions ===
  
<code>steam-run</code> is a helper that can be used to run external programs in the steam FHS environment. This means that some third-party software, mostly games, can be run easily on NixOS using <code>steam-run</code>. Before trying other solutions, try starting your game this way, where <code>start-game.sh</code> is the script used to start the game on Linux.
+
By default, Steam looks for custom Proton versions such as GE-Proton in <code>~/.steam/root/compatibilitytools.d</code>. Additionally the environment variable <code>STEAM_EXTRA_COMPAT_TOOLS_PATHS</code> can be set to change or add to the paths which steam searches for custom Proton versions.
  
<syntaxhighlight lang="commands">
+
== See also ==
$ steam-run ./start-game.sh
+
[[Explaining the current Steam Package build]]
</syntaxhighlight>
 

Latest revision as of 10:53, 6 April 2024

This page is intended to explain how to run Steam, Steam games as well as proprietary DRM-free games under NixOS. A dedicated Games page lists games and reports on their successful execution on NixOS.

Install

To install the Steam package and enable all the system options necessary to allow it to run:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
programs.steam = {
  enable = true;
  remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
  dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
};


Note: Enabling steam installs several unfree packages. If you are using allowUnfreePredicate you will need to ensure that your configurations permit all of them.
{
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "steam"
    "steam-original"
    "steam-run"
  ];
}


steam-tui

If you want the steam-tui client you'll have to install it, but since it relies on `steamcmd` being set up, you'll have to set that up, just to generate the right files.

nix-shell -p steamcmd --run steamcmd

And then log in:

login <username> <password> <steam 2fa password>

After that, steam-tui should start fine.

FHS environment only

This will only make partial installation - provide the script, which creates the typical environment expected by proprietary games and software on regular Linux, allowing to run such software without patching. Useful if you plan to run games downloaded from the internet.

Note that this is not necessary for clients installed from Nixpkgs (like Minigalaxy or Itch), which already use the FHS environment.

There are two options to install the FHS environment. The first is to install steam-run.

Example snippet of configuration.nix:

  environment.systemPackages = with pkgs; [
    steam-run
  ];

Another option, in case you need more flexibility, is to directly reference the part of steam metapackage.

Example snippet of configuration.nix:

  environment.systemPackages = with pkgs; [
    (steam.override { /* Your overrides here */ }).run
  ];

Install the game by setting the executable attribute on the installer and then running it via steam-run ./your_installer.sh. After installation, edit the "~/.local/share/applications/your_game.desktop" and replace the exec line from Exec="/home/user/game/start.sh" "" with Exec="steam-run" "/home/user/game/start.sh".

Adding missing dependencies

In some cases, you may need to override steam to provide missing dependencies. Use the programs.steam.package for this.

Bumblebee and Primus

  programs.steam.package = pkgs.steam.override {
     withPrimus = true;
     extraPkgs = pkgs: [ bumblebee glxinfo ];
  };

Java

  programs.java.enable = true; 
  programs.steam.package = pkgs.steam.override { withJava = true; };

gamescope

To use the gamescope compositor, which enables features such as resolution upscaling and stretched aspect ratios (such as 4:3), set

programs.steam.gamescopeSession.enable = true;

in your system configuration.

Troubleshooting

For all issues: first run steam through the terminal and read the output.

Steam fails to start. What do I do?

strace then open a bug report.

Steam is not updated

When you restart Steam after an update, it starts the old version. (#181904)

A workaround is to remove the user files in /home/<user>/.local/share/Steam and setup Steam again.

Game fails to start

Games may fail to start because they lack dependencies (this should be added to the script, for now), or because they cannot be patched. The steps to launch a game directly are:

  • Patch the script/binary if you can
  • Add a file named steam_appid.txt in the binary folder, with the appid as contents (it can be found in the stdout from steam)
  • Using the LD_LIBRARY_PATH from the nix/store steam script, with some additions, launch the game binary
 LD_LIBRARY_PATH=~/.steam/bin32:$LD_LIBRARY_PATH:/nix/store/pfsa... blabla ...curl-7.29.0/lib:. ./Osmos.bin32 (if you could not patchelf the game, call ld.so directly with the binary as parameter)

Note: If a game gets stuck on Installing scripts, check for a DXSETUP.EXE process and run it manually, then restart the game launch.

Changing the driver on AMD GPUs

Sometimes, changing the driver on AMD GPUs helps. To try this, first, install multiple drivers such as radv and amdvlk:

hardware.opengl = {
  ## radv: an open-source Vulkan driver from freedesktop
  driSupport = true;
  driSupport32Bit = true;

  ## amdvlk: an open-source Vulkan driver from AMD
  extraPackages = [ pkgs.amdvlk ];
  extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
};

In the presence of both drivers, Steam will default to amdvlk. The amdvlk driver can be considered more correct regarding Vulkan specification implementation, but less performant than radv. However, this tradeoff between correctness and performance can sometimes make or break the gaming experience.

To "reset" your driver to radv when both radv and amdvlk are installed, set either AMD_VULKAN_ICD = "RADV" or VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json" environment variable. For example, if you start Steam from the shell, you can enable radv for the current session by running AMD_VULKAN_ICD="RADV" steam. If you are unsure which driver you currently use, you can launch a game with MangoHud enabled, which has the capability to show what driver is currently in use.

SteamVR

The setcap issue at SteamVR start can be fixed with:

sudo setcap CAP_SYS_NICE+ep ~/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher

Known issues

"Project Zomboid" may report "couldn't determine 32/64 bit of java". This is not related to java at all, it carries its own outdated java binary that refuses to start if path contains non-Latin characters. Check for errors by directly starting local java binary within steam-run bash.

Resetting your password through the Steam app may fail at the CAPTCHA step repeatedly, with Steam itself reporting that the CAPTCHA was not correct, even though the CAPTCHA UI shows success. Resetting password through the Steam website should work around that.

Steam hardware

If you are using a Steam Controller or a Valve Index, you will want to add hardware.steam-hardware.enable = true; to your configuration.

Note that this is already enabled with programs.steam.enable = true;.

Proton

NixOS 21.11

From this version of NixOS onwards, you should be able to play most games with Proton.

Custom Proton versions

By default, Steam looks for custom Proton versions such as GE-Proton in ~/.steam/root/compatibilitytools.d. Additionally the environment variable STEAM_EXTRA_COMPAT_TOOLS_PATHS can be set to change or add to the paths which steam searches for custom Proton versions.

See also

Explaining the current Steam Package build