Jump to content

Steam: Difference between revisions

From NixOS Wiki
imported>Vegai
Add a mention where the skins dir is
Lukec (talk | contribs)
m programs.gamemode should be outside the programs.steam config
 
(108 intermediate revisions by 58 users not shown)
Line 1: Line 1:
{{outdated}}
<languages/>
This page is intended to describe the current state of Steam under Nixos and to discuss what the problems are in packaging it and how we can approach solving them.
<translate>
<!--T:1-->
[https://store.steampowered.com/ Steam] is a digital distribution platform for video games, offering a vast library for purchase, download, and management. On NixOS, Steam is generally easy to install and use, often working "out-of-the-box". It supports running many Windows games on Linux through its compatibility layer, Proton.<ref>https://store.steampowered.com/</ref>
</translate>


== I want to play ==
<translate>
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.
== Installation == <!--T:2-->
</translate>


== Master/Unstable branch ==
<translate>
Install "steam" package. Run "steam". Many of the games will just work.
==== Shell ==== <!--T:3-->
</translate>


== Stable branch ==
<translate>
Install "steam" and "steamChrootEnv" packages. Run:
<!--T:4-->
To temporarily use Steam-related tools like <code>steam-run</code> (for FHS environments) or <code>steamcmd</code> (for server management or tools like steam-tui setup) in a shell environment, you can run:
</translate>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo init-steam-chrootenv
nix-shell -p steam-run # For FHS environment
sudo mount-steam-chrootenv
nix-shell -p steamcmd  # For steamcmd
load-steam-chrootenv
steam
</syntaxhighlight>
</syntaxhighlight>
To destroy the chroot env, run:
<translate>
<syntaxhighlight lang="bash">
<!--T:5-->
sudo umount-steam-chrootenv
This provides the tools in your current shell without adding them to your system configuration. For <code>steamcmd</code> to work correctly for some tasks (like initializing for steam-tui), you might need to run it once to generate necessary files, as shown in the `steam-tui` section.
sudo destroy-steam-chrootenv
</translate>
 
<translate>
==== System setup ==== <!--T:6-->
</translate>
 
<translate>
<!--T:7-->
To install the [[Steam]] package and enable all the system options necessary to allow it to run, add the following to your <code>/etc/nixos/configuration.nix</code>:
</translate>
<syntaxhighlight lang="nix">
# Example for /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
};
 
# Optional: If you encounter amdgpu issues with newer kernels (e.g., 6.10+ reported issues),
# you might consider using the LTS kernel or a known stable version.
# boot.kernelPackages = pkgs.linuxPackages_lts; # Example for LTS
</syntaxhighlight>
</syntaxhighlight>
<translate>
<!--T:8-->
[https://news.ycombinator.com/item?id=41549030 Anecdata on kernel 6.10 issues]
</translate>


== Description of the package ==
{{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.
Steam is distributed as a .deb file, for now only as an i686 package (the amd64 package only has documentation). When unpacked, it has a script called steam that in ubuntu (their target distro) would go to /usr/bin. When run for the first time, this script copies some files to the user's home, which include another script that is the ultimate responsible for launching the steam binary, which is also in $HOME.
<syntaxhighlight lang="nix">
{
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "steam"
    "steam-unwrapped"
  ];
}
</syntaxhighlight>
}}


== Nix problems and constraints ==
<translate>
* We don't have /bin/bash and many scripts point there. Similarly for /usr/bin/python, for some functionality.
== Configuration == <!--T:9-->
* We don't have the dynamic loader in /lib
</translate>
* The steam.sh script in $HOME could not be patched last I tried, as it is checked and rewritten by steam
* The steam binary cannot be patched, it's also checked


== Approaches ==
<translate>
=== chroot ===
<!--T:10-->
This is the current approach, documented here: http://sandervanderburg.blogspot.nl/2013/09/composing-fhs-compatible-chroot.html
Basic Steam features can be enabled directly within the <code>programs.steam</code> attribute set:
* Pros:
</translate>
** it would allow us to have binaries in the expected paths without disrupting the system
<syntaxhighlight lang="nix">
** Steam itself, as well as Valve games and perhaps others like to checksum their executables, so patching does not work
programs.steam = {
* Cons: performance?
  enable = true; # Master switch, already covered in installation
  remotePlay.openFirewall = true;  # For Steam Remote Play
  dedicatedServer.openFirewall = true; # For Source Dedicated Server hosting
  # Other general flags if available can be set here.
};
# Tip: For improved gaming performance, you can also enable GameMode:
# programs.gamemode.enable = true;
</syntaxhighlight>
<translate>
<!--T:11-->
If you are using a Steam Controller or a Valve Index, ensure Steam hardware support is enabled. This is typically handled by <code>programs.steam.enable = true;</code> which sets <code>hardware.steam-hardware.enable = true;</code> implicitly. You can verify or explicitly set it if needed:
</translate>
<syntaxhighlight lang="nix">
hardware.steam-hardware.enable = true;
</syntaxhighlight>
<translate>
== Tips and tricks == <!--T:12-->
</translate>


=== Link bash to /bin and glibc/lib to /lib and be happy ===
<translate>
* Pros: easy, works
=== Gamescope Compositor / "Boot to Steam Deck" === <!--T:13-->
* Cons: not very nix-compliant
</translate>
<translate>
<!--T:14-->
Gamescope can function as a minimal desktop environment, meaning you can launch it from a TTY and have an experience very similar to the Steam Deck hardware console.
</translate>
<syntaxhighlight lang="nix">
# Clean Quiet Boot
boot.kernelParams = [ "quiet" "splash" "console=/dev/null" ];
boot.plymouth.enable = true;


=== Workaround the scripts and launch steam directly ===
programs.gamescope = {
* Pros: not so hard
  enable = true;
* Cons: this only solves the part concerned with running steam. What about the games? We can patch some of them, but at least Team Fortress is checked and rewritten if modified
  capSysNice = true;
};
programs.steam.gamescopeSession.enable = true; # Integrates with programs.steam


This is the approach that I (page) took in my github branch: https://github.com/cpages/nixpkgs/tree/steam
# Gamescope Auto Boot from TTY (example)
services.xserver.enable = false; # Assuming no other Xserver needed
services.getty.autologinUser = "USERNAME_HERE";


=== Intercept Steam's calls with LD_PRELOAD or the like ===
services.greetd = {
* Pros: more robust
  enable = true;
* Cons: difficult to achieve and may be broken by changes in the binary
  settings = {
    default_session = {
      command = "${pkgs.gamescope}/bin/gamescope -W 1920 -H 1080 -f -e --xwayland-count 2 --hdr-enabled --hdr-itm-enabled -- steam -pipewire-dmabuf -gamepadui -steamdeck -steamos3 > /dev/null 2>&1";
      user = "USERNAME_HERE";
    };
  };
};
</syntaxhighlight>


aszlig started working in this in his branch: https://github.com/aszlig/nixpkgs/tree/steam
<translate>
=== steam-tui === <!--T:15-->
</translate>
<translate>
<!--T:16-->
If you want the steam-tui client, you'll have to install it. It relies on <code>steamcmd</code> being set up, so you'll need to run <code>steamcmd</code> once to generate the necessary configuration files.
First, ensure <code>steamcmd</code> is available (e.g., via <code>nix-shell -p steamcmd</code> or by adding it to <code>environment.systemPackages</code>), then run:
</translate>
<syntaxhighlight lang="bash">
steamcmd +quit # This initializes steamcmd's directory structure
</syntaxhighlight>
<translate>
<!--T:17-->
Then install and run `steam-tui`. You may need to log in within `steamcmd` first if `steam-tui` has issues:
</translate>
<syntaxhighlight lang="bash">
# (Inside steamcmd prompt, if needed for full login before steam-tui)
# login <username> <password> <steam_2fa_code>
# quit
</syntaxhighlight>
<translate>
<!--T:18-->
After setup, <code>steam-tui</code> (if installed e.g. via <code>home.packages</code> or <code>environment.systemPackages</code>) should start fine.
</translate>


=== But what about the games? ===
<translate>
You can install any of the games normally, but they will fail to start. From this step on, you're in the unsupported realm. Some games can be patchelfed:
=== FHS environment only === <!--T:19-->
<syntaxhighlight lang="bash">
</translate>
patchelf --set-interpreter /path/to/ld.so game_binary (you can get the path to an x86 ld.so looking at the steam script in the store, for me /nix/store/xh0q23rgqbjfrh3zfv4jyxvcvjnxqh64-glibc-2.15.0/lib/ld-linux.so.2)
<translate>
<!--T:20-->
To run proprietary games or software downloaded from the internet that expect a typical Linux Filesystem Hierarchy Standard (FHS), you can use <code>steam-run</code>. This provides an FHS-like environment without needing to patch the software.
Note that this is not necessary for clients installed from Nixpkgs (like Minigalaxy or Itch), which already use the FHS environment as needed.
There are two options to make <code>steam-run</code> available:
1. Install <code>steam-run</code> system-wide or user-specifically:
</translate>
<syntaxhighlight lang="nix">
# In /etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [
  steam-run
];
</syntaxhighlight>
<translate>
<!--T:21-->
2. If you need more flexibility or want to use an overridden Steam package's FHS environment:
</translate>
<syntaxhighlight lang="nix">
# In /etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [
  (steam.override { /* Your overrides here */ }).run
];
</syntaxhighlight>
<translate>
=== Proton === <!--T:22-->
</translate>
<translate>
<!--T:23-->
You should be able to play most Windows games using Proton. If a game has a native Linux version that causes issues on NixOS, you can force the use of Proton by selecting a specific Proton version in the game's compatibility settings in Steam.
</translate>
<translate>
<!--T:24-->
By default, Steam also looks for custom Proton versions in <code>~/.steam/root/compatibilitytools.d</code>. The environment variable <code>STEAM_EXTRA_COMPAT_TOOLS_PATHS</code> can be set to add other search paths.
</translate>
<translate>
<!--T:25-->
Declarative install of custom Proton versions (e.g. GE-Proton):
</translate>
<syntaxhighlight lang="nix">
programs.steam.extraCompatPackages = with pkgs; [
  proton-ge-bin
];
</syntaxhighlight>
<translate>
<!--T:26-->
Manual management of multiple Proton versions can be done with ProtonUp-Qt:
</translate>
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
  protonup-qt
];
</syntaxhighlight>
<translate>
=== Overriding the Steam package === <!--T:27-->
</translate>
<translate>
<!--T:28-->
In some cases, you may need to override the default Steam package to provide missing dependencies or modify its build. Use the <code>programs.steam.package</code> option for this. Steam on NixOS runs many games in an FHS environment, but the Steam client itself or certain tools might need extra libraries.
</translate>
<translate>
<!--T:29-->
Example: Adding Bumblebee and Primus (for NVIDIA Optimus):
</translate>
<syntaxhighlight lang="nix">
programs.steam.package = pkgs.steam.override {
  extraPkgs = pkgs': with pkgs'; [ bumblebee primus ];
};
 
# For 32-bit applications with Steam, if using steamFull:
# programs.steam.package = pkgs.steamFull.override { extraPkgs = pkgs': with pkgs'; [ bumblebee primus ]; };
</syntaxhighlight>
 
<translate>
<!--T:30-->
Example: Adding Xorg libraries for Gamescope (when used within Steam):
</translate>
<syntaxhighlight lang="nix">
programs.steam.package = pkgs.steam.override {
  extraPkgs = pkgs': with pkgs'; [
    xorg.libXcursor
    xorg.libXi
    xorg.libXinerama
    xorg.libXScrnSaver
    libpng
    libpulseaudio
    libvorbis
    stdenv.cc.cc.lib # Provides libstdc++.so.6
    libkrb5
    keyutils
    # Add other libraries as needed
  ];
};
</syntaxhighlight>
</syntaxhighlight>
You might also need patching some scripts. That all depends on each one. You can then press play from steam and if you're lucky that'll be it!


<translate>
== Troubleshooting == <!--T:31-->
</translate>


== Troubleshooting ==
<translate>
I was sure you would reach this part.
<!--T:32-->
For all issues: first run <code>steam -dev -console</code> through the terminal and read the output.
</translate>


=== Steam fails to start. What do I do? ===
<translate>
strace is your friend.
=== Steam fails to start. What do I do? === <!--T:33-->
</translate>
<translate>
<!--T:34-->
Run <code>strace steam -dev -console 2> steam.logs</code> in the terminal. If <code>strace</code> is not installed, temporarily install it using <code>nix-shell -p strace</code> or <code>nix run nixpkgs#strace -- steam -dev -console 2> steam.logs</code> (if using Flakes). After that, create a bug report. <!-- This is vague. Where should the user create a bug report?  -->
</translate>


=== Game X fails to start ===
<translate>
=== Steam is not updated === <!--T:35-->
</translate>
<translate>
<!--T:36-->
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/&lt;USER&gt;/.local/share/Steam/userdata</code>. This can be done with <code>rm -rf /home/&lt;USER&gt;/.local/share/Steam/userdata</code> in the terminal or with your file manager. After that, Steam can be set up again by restarting.
</translate>
 
<translate>
=== Game fails to start === <!--T:37-->
</translate>
<translate>
<!--T:38-->
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
* 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)
* 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
* Using the LD_LIBRARY_PATH from the nix/store steam script, with some additions, launch the game binary
</translate>
<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.
<translate>
<!--T:39-->
Note: If a game gets stuck on Installing scripts, check for a DXSETUP.EXE process and run it manually, then restart the game launch.
</translate>


=== Using the FOSS Radeon drivers ===
<translate>
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 <!-- this is not recommended due radv drivers performing better and generally more stable than amdvlk. My suggestion remove this section. source: https://forums.guru3d.com/threads/the-mesa-radv-amdvlk-thread.449774/ -->==== <!--T:40-->
</translate>
{{note|This is not recommended because radv drivers tend to perform better and are generally more stable than amdvlk.}}
<translate>
<!--T:41-->
Sometimes, changing the driver on AMD GPUs helps. To try this, first, install multiple drivers such as radv and amdvlk:
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
(steamPackages.override { newLibcpp = true; }).steam-chrootenv
hardware.graphics = {
  ## radv: an open-source Vulkan driver from freedesktop
  enable32Bit = true;
 
  ## amdvlk: an open-source Vulkan driver from AMD
  extraPackages = [ pkgs.amdvlk ];
  extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
};
</syntaxhighlight>
</syntaxhighlight>
[https://github.com/NixOS/nixpkgs/pull/12404 in your config] if you get an error like
<translate>
 
<!--T:42-->
libGL error: unable to load driver: radeonsi_dri.so
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.
libGL error: driver pointer missing
</translate>
libGL error: failed to load driver: radeonsi
<translate>
libGL error: unable to load driver: swrast_dri.so
<!--T:43-->
libGL error: failed to load driver: swrast
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.
</translate>
<translate>
=== SteamVR === <!--T:44-->
</translate>
<translate>
<!--T:45-->
The setcap issue at SteamVR start can be fixed with:
<code>sudo setcap CAP_SYS_NICE+ep ~/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher</code>
</translate>
<translate>
=== Gamescope fails to launch when used within Steam === <!--T:46-->
</translate>
<translate>
<!--T:47-->
Gamescope may fail to start due to missing Xorg libraries. ([https://github.com/NixOS/nixpkgs/issues/214275 #214275]) To resolve this override the steam package to add them:
</translate>
<syntaxhighlight lang="nix">
programs.steam.package = pkgs.steam.override {
  extraPkgs = pkgs': with pkgs'; [
    xorg.libXcursor
    xorg.libXi
    xorg.libXinerama
    xorg.libXScrnSaver
    libpng
    libpulseaudio
    libvorbis
    stdenv.cc.cc.lib # Provides libstdc++.so.6
    libkrb5
    keyutils
    # Add other libraries as needed
  ];
};
</syntaxhighlight>
<translate>
=== Udev rules for additional Gamepads === <!--T:48-->
</translate>
<translate>
<!--T:49-->
In specific scenarios gamepads, might require some additional configuration in order to function properly in the form of udev rules. This can be achieved with <code>services.udev.extraRules</code>.
</translate>
<translate>
<!--T:50-->
The following example is for the 8bitdo Ultimate Bluetooth controller, different controllers will require knowledge of the vendor and product ID for the device:
</translate>
<syntaxhighlight lang="nix">
  services.udev.extraRules = ''
    SUBSYSTEM=="input", ATTRS{idVendor}=="2dc8", ATTRS{idProduct}=="3106", MODE="0660", GROUP="input"
  '';
</syntaxhighlight>
<translate>
<!--T:51-->
To find the vendor and product ID of a device [https://search.nixos.org/packages?channel=unstable&show=usbutils&from=0&size=50&sort=relevance&type=packages&query=usbutils usbutils] might be useful
</translate>
<translate>
=== Known issues === <!--T:52-->
</translate>
<translate>
<!--T:53-->
"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>.


=== Known issues ===
<!--T:55-->
# No java in steam chrootenv. Games affected: Towns:
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 lang="console">
</translate>
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found
<translate>
</syntaxhighlight>
== References == <!--T:54-->
</translate>


=== HiDPI ===
[[Category:Applications]]
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/.
[[Category:Gaming]]

Latest revision as of 19:43, 18 June 2025

Steam is a digital distribution platform for video games, offering a vast library for purchase, download, and management. On NixOS, Steam is generally easy to install and use, often working "out-of-the-box". It supports running many Windows games on Linux through its compatibility layer, Proton.[1]

Installation

Shell

To temporarily use Steam-related tools like steam-run (for FHS environments) or steamcmd (for server management or tools like steam-tui setup) in a shell environment, you can run:

nix-shell -p steam-run # For FHS environment
nix-shell -p steamcmd  # For steamcmd

This provides the tools in your current shell without adding them to your system configuration. For steamcmd to work correctly for some tasks (like initializing for steam-tui), you might need to run it once to generate necessary files, as shown in the `steam-tui` section.

System setup

To install the Steam package and enable all the system options necessary to allow it to run, add the following to your /etc/nixos/configuration.nix:

# Example for /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
};

# Optional: If you encounter amdgpu issues with newer kernels (e.g., 6.10+ reported issues),
# you might consider using the LTS kernel or a known stable version.
# boot.kernelPackages = pkgs.linuxPackages_lts; # Example for LTS

Anecdata on kernel 6.10 issues

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-unwrapped"
  ];
}

Configuration

Basic Steam features can be enabled directly within the programs.steam attribute set:

programs.steam = {
  enable = true; # Master switch, already covered in installation
  remotePlay.openFirewall = true;  # For Steam Remote Play
  dedicatedServer.openFirewall = true; # For Source Dedicated Server hosting
  # Other general flags if available can be set here.
};
# Tip: For improved gaming performance, you can also enable GameMode:
# programs.gamemode.enable = true;

If you are using a Steam Controller or a Valve Index, ensure Steam hardware support is enabled. This is typically handled by programs.steam.enable = true; which sets hardware.steam-hardware.enable = true; implicitly. You can verify or explicitly set it if needed:

hardware.steam-hardware.enable = true;

Tips and tricks

Gamescope Compositor / "Boot to Steam Deck"

Gamescope can function as a minimal desktop environment, meaning you can launch it from a TTY and have an experience very similar to the Steam Deck hardware console.

# Clean Quiet Boot
boot.kernelParams = [ "quiet" "splash" "console=/dev/null" ];
boot.plymouth.enable = true;

programs.gamescope = {
  enable = true;
  capSysNice = true;
};
programs.steam.gamescopeSession.enable = true; # Integrates with programs.steam

# Gamescope Auto Boot from TTY (example)
services.xserver.enable = false; # Assuming no other Xserver needed
services.getty.autologinUser = "USERNAME_HERE";

services.greetd = {
  enable = true;
  settings = {
    default_session = {
      command = "${pkgs.gamescope}/bin/gamescope -W 1920 -H 1080 -f -e --xwayland-count 2 --hdr-enabled --hdr-itm-enabled -- steam -pipewire-dmabuf -gamepadui -steamdeck -steamos3 > /dev/null 2>&1";
      user = "USERNAME_HERE";
    };
  };
};

steam-tui

If you want the steam-tui client, you'll have to install it. It relies on steamcmd being set up, so you'll need to run steamcmd once to generate the necessary configuration files. First, ensure steamcmd is available (e.g., via nix-shell -p steamcmd or by adding it to environment.systemPackages), then run:

steamcmd +quit # This initializes steamcmd's directory structure

Then install and run `steam-tui`. You may need to log in within `steamcmd` first if `steam-tui` has issues:

# (Inside steamcmd prompt, if needed for full login before steam-tui)
# login <username> <password> <steam_2fa_code>
# quit

After setup, steam-tui (if installed e.g. via home.packages or environment.systemPackages) should start fine.

FHS environment only

To run proprietary games or software downloaded from the internet that expect a typical Linux Filesystem Hierarchy Standard (FHS), you can use steam-run. This provides an FHS-like environment without needing to patch the software. Note that this is not necessary for clients installed from Nixpkgs (like Minigalaxy or Itch), which already use the FHS environment as needed. There are two options to make steam-run available: 1. Install steam-run system-wide or user-specifically:

# In /etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [
  steam-run
];

2. If you need more flexibility or want to use an overridden Steam package's FHS environment:

# In /etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [
  (steam.override { /* Your overrides here */ }).run
];

Proton

You should be able to play most Windows games using Proton. If a game has a native Linux version that causes issues on NixOS, you can force the use of Proton by selecting a specific Proton version in the game's compatibility settings in Steam. By default, Steam also looks for custom Proton versions in ~/.steam/root/compatibilitytools.d. The environment variable STEAM_EXTRA_COMPAT_TOOLS_PATHS can be set to add other search paths. Declarative install of custom Proton versions (e.g. GE-Proton):

programs.steam.extraCompatPackages = with pkgs; [
  proton-ge-bin
];

Manual management of multiple Proton versions can be done with ProtonUp-Qt:

environment.systemPackages = with pkgs; [
  protonup-qt
];

Overriding the Steam package

In some cases, you may need to override the default Steam package to provide missing dependencies or modify its build. Use the programs.steam.package option for this. Steam on NixOS runs many games in an FHS environment, but the Steam client itself or certain tools might need extra libraries. Example: Adding Bumblebee and Primus (for NVIDIA Optimus):

programs.steam.package = pkgs.steam.override {
  extraPkgs = pkgs': with pkgs'; [ bumblebee primus ];
};

# For 32-bit applications with Steam, if using steamFull:
# programs.steam.package = pkgs.steamFull.override { extraPkgs = pkgs': with pkgs'; [ bumblebee primus ]; };

Example: Adding Xorg libraries for Gamescope (when used within Steam):

programs.steam.package = pkgs.steam.override {
  extraPkgs = pkgs': with pkgs'; [
    xorg.libXcursor
    xorg.libXi
    xorg.libXinerama
    xorg.libXScrnSaver
    libpng
    libpulseaudio
    libvorbis
    stdenv.cc.cc.lib # Provides libstdc++.so.6
    libkrb5
    keyutils
    # Add other libraries as needed
  ];
};

Troubleshooting

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

Steam fails to start. What do I do?

Run strace steam -dev -console 2> steam.logs in the terminal. If strace is not installed, temporarily install it using nix-shell -p strace or nix run nixpkgs#strace -- steam -dev -console 2> steam.logs (if using Flakes). After that, create 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/userdata. This can be done with rm -rf /home/<USER>/.local/share/Steam/userdata in the terminal or with your file manager. After that, Steam can be set up again by restarting.

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

Note: This is not recommended because radv drivers tend to perform better and are generally more stable than amdvlk.

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

hardware.graphics = {
  ## radv: an open-source Vulkan driver from freedesktop
  enable32Bit = 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

Gamescope fails to launch when used within Steam

Gamescope may fail to start due to missing Xorg libraries. (#214275) To resolve this override the steam package to add them:

programs.steam.package = pkgs.steam.override {
  extraPkgs = pkgs': with pkgs'; [
    xorg.libXcursor
    xorg.libXi
    xorg.libXinerama
    xorg.libXScrnSaver
    libpng
    libpulseaudio
    libvorbis
    stdenv.cc.cc.lib # Provides libstdc++.so.6
    libkrb5
    keyutils
    # Add other libraries as needed
  ];
};

Udev rules for additional Gamepads

In specific scenarios gamepads, might require some additional configuration in order to function properly in the form of udev rules. This can be achieved with services.udev.extraRules. The following example is for the 8bitdo Ultimate Bluetooth controller, different controllers will require knowledge of the vendor and product ID for the device:

  services.udev.extraRules = ''
    SUBSYSTEM=="input", ATTRS{idVendor}=="2dc8", ATTRS{idProduct}=="3106", MODE="0660", GROUP="input"
  '';

To find the vendor and product ID of a device usbutils might be useful

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.

References