Steam: Difference between revisions

From NixOS Wiki
imported>Polypoyo
m →‎steam-tui: change "f2a" to "2fa"
imported>Appetrosyan
Clarify installation instructions
Line 4: Line 4:


== Install ==
== Install ==
Firstly, you should install Steam itself:
{{file|/etc/configuration.nix|nix|<nowiki>
{
  environment.systemPackages = with pkgs; [
    # ...
    steam
    # ...
  ];
}
</nowiki>}}
{{warning|The above step is insufficient, just adding <code>steam</code> to your package list is not going to work, since it won't enable all necessary system options. Please enable steam as shown below.}}
The following options should be enabled to allow steam to run.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 12: Line 24:
   };
   };
</syntaxhighlight>
</syntaxhighlight>
{{warning|Just adding <code>steam</code> to your package list is not going to work, since it won't enable all necessary system options. Please enable steam as shown above.}}


{{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.}}
 
 
{{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>
{
{
Line 24: Line 37:
}
}
</syntaxHighlight>
</syntaxHighlight>
}}


=== steam-tui ===
=== steam-tui ===

Revision as of 14:39, 7 November 2022

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

Firstly, you should install Steam itself:

/etc/configuration.nix
{
  environment.systemPackages = with pkgs; [
    # ...
    steam
    # ...
  ];
}
Warning: The above step is insufficient, just adding steam to your package list is not going to work, since it won't enable all necessary system options. Please enable steam as shown below.

The following options should be enabled to allow steam to run.

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


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

  nixpkgs.config.packageOverrides = pkgs: {
    steam = pkgs.steam.override {
      extraPkgs = pkgs: with pkgs; [
        libgdiplus
      ];
    };
  };

Bumblebee and Primus

  environment.systemPackages = with pkgs; [
    (steam.override {
       withPrimus = true;
       extraPkgs = pkgs: [ bumblebee glxinfo ];
    }).run
  ];

Java

  programs.java.enable = true; 
  environment.systemPackages = with pkgs; [
    (steam.override { withJava = true; })
  ];

You can test java availability by invoking chrooted bash instance: steam-run bash and then typing: java -version. Can be combined with extra packages above.

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.

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)

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.

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.

GE-Proton (GloriousEggroll)

Note: By default, Steam on NixOS won't see any manually-installed Proton-GE versions. In order for Steam to be able to find these, you need to have the environment variable STEAM_EXTRA_COMPAT_TOOLS_PATHS set in your login session.

Here is an example configuration.nix excerpt that would provide that, using the (mostly) standard location (this one happens to also provide environment variables that help things conform to the XDG Base Directory Specification):

    environment.sessionVariables = rec {
      XDG_CACHE_HOME  = "\${HOME}/.cache";
      XDG_CONFIG_HOME = "\${HOME}/.config";
      XDG_BIN_HOME    = "\${HOME}/.local/bin";
      XDG_DATA_HOME   = "\${HOME}/.local/share";
      # Steam needs this to find Proton-GE
      STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d";
      # note: this doesn't replace PATH, it just adds this to it
      PATH = [ 
        "\${XDG_BIN_HOME}"
      ];
    };
Note: As of 8/2022, the protonup auto-updater in nixpkgs is currently broken due to a naming convention change; see discussion here which suggests using a fixed fork (which is not yet part of nixpkgs) until it is patched or a PR is accepted. (Or you can simply just continue to manually install new versions.)

See also

https://nixos.wiki/wiki/Explaining_the_current_Steam_Package_build