Steam

From NixOS Wiki
Revision as of 15:11, 5 April 2024 by Sen (talk | contribs) (→‎Troubleshooting: Steam outputs more logs if -dev is defined and -console is sometimes useful)

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:

/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 -dev -console 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