Steam: Difference between revisions

From NixOS Wiki
imported>Kevincox
Removed HiDPI section, steam has had good support for a while now.
imported>Artturin
use steam module and clean up
Line 1: Line 1:
{{unfree}}
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.  
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.  


== Prerequisites ==
If you are using 64-bit system and plan to also run 32-bit code (some games are 32-bit only) - add <syntaxhighlight lang="nix" inline>hardware.opengl.driSupport32Bit = true</syntaxhighlight> and <syntaxhighlight lang="nix" inline>hardware.pulseaudio.support32Bit = true</syntaxhighlight> (in case you are using pulseaudio) to your configuration.
Example snippet of <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
  ...
  hardware.opengl.driSupport32Bit = true;
  hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ];
  hardware.pulseaudio.support32Bit = true;
  ...
</syntaxHighlight>
See the relevant section of the manual: https://nixos.org/manual/nixpkgs/stable/#sec-steam-play. A possible error when not enabling 32bit support is an error message "glXChooseVisual failed".


== Installation ==
== Installation ==
Several installation options exist.  
Several installation options exist.  


=== Pure steam client ===
== Normal install ==
If you need Steam client, install it with<syntaxhighlight lang="nix" inline>steam</syntaxhighlight> package.
 
Example snippet of <code>configuration.nix</code>:
<syntaxhighlight lang="nix">
<syntaxHighlight lang=nix>
  programs.steam.enable = true;
  environment.systemPackages = with pkgs; [
</syntaxhighlight>
  ...
  steam
  ];
  ...
</syntaxHighlight>


=== Native steam client ===
=== Native steam client ===
Line 33: Line 17:
Example snippet of <code>configuration.nix</code>:
Example snippet of <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
   environment.systemPackages = with pkgs; [
   nixpkgs.config.packageOverrides = pkgs: {
  ...
    steam = pkgs.steam.override {
  (steam.override { nativeOnly = true; })
      nativeOnly = true;
];
    };
   ...
  };
   programs.steam.enable = true;
</syntaxHighlight>
</syntaxHighlight>


Line 47: Line 32:
Example snippet of <code>configuration.nix</code>:
Example snippet of <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
  ...
   environment.systemPackages = with pkgs; [
   environment.systemPackages = with pkgs; [
  ...
   steam-run-native
   steam-run-native
   ];
   ];
  ...
</syntaxHighlight>
</syntaxHighlight>


unfree
Other option, in case you need more flexibility, is to directly reference to the part of steam metapackage instead. In fact, <code>steam-run-native</code> above is just a wrapper linking to <code>steam.run</code>.
Other option, in case you need more flexibility, is to directly reference to the part of steam metapackage instead. In fact, <code>steam-run-native</code> above is just a wrapper linking to <code>steam.run</code>.


Example snippet of <code>configuration.nix</code>:
Example snippet of <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
  ...
   environment.systemPackages = with pkgs; [
   environment.systemPackages = with pkgs; [
  ...
   (steam.override { nativeOnly = true; }).run
   (steam.override { nativeOnly = true; }).run
   ];
   ];
  ...
</syntaxHighlight>
</syntaxHighlight>
This builds same result as <code>steam-run-native</code> above.
This builds same result as <code>steam-run-native</code> above.
Line 72: Line 52:
== Adding missing dependencies ==
== Adding missing dependencies ==


This can be done this way:
may also need <code>nativeOnly = true;</code> but i have not tested
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
   ...
   nixpkgs.config.packageOverrides = pkgs: {
  environment.systemPackages = with pkgs; [
    steam = pkgs.steam.override {
  ...
      extraPkgs = pkgs: [
  (steam.override { extraPkgs = pkgs: [ mono gtk3 gtk3-x11 libgdiplus zlib ]; nativeOnly = true; }).run
        libgdiplus
   ];
      ];
...
    };
   };
</syntaxHighlight>
</syntaxHighlight>


=== Bumblebee and Primus ===
=== Bumblebee and Primus ===
This can be done this way:
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
  ...
   environment.systemPackages = with pkgs; [
   environment.systemPackages = with pkgs; [
  ...
   (steam.override { withPrimus = true; extraPkgs = pkgs: [ bumblebee glxinfo ]; nativeOnly = true; }).run
   (steam.override { withPrimus = true; extraPkgs = pkgs: [ bumblebee glxinfo ]; nativeOnly = true; }).run
   ];
   ];
...
</syntaxHighlight>
</syntaxHighlight>


=== Java ===
=== Java ===
Example snippet of <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
   ...
   programs.java.enable = true;  
programs.java.enable = true;  
    environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
   (steam.override { withJava = true; })
   ...
  ];
(steam.override { withJava = true; })
];
  ...
</syntaxHighlight>
</syntaxHighlight>


Line 108: Line 81:


== Limit user access ==
== Limit user access ==
Example snippet of <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
  ...
   users.users.<your-username>.packages = [
   users.users.<your-username>.packages = [
     pkgs.steam
     pkgs.steam
   ];
   ];
...
</syntaxHighlight>
</syntaxHighlight>


Line 146: Line 116:
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 configurations.
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 configurations.


[[Category:Guide]]
[[Category:Applications]]

Revision as of 02:40, 12 January 2021

Note: This package is unfree and requires extra steps to install.

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.


Installation

Several installation options exist.

Normal install

  programs.steam.enable = true;

Native steam client

If you want Steam client to use NixOS libraries instead of Steam-provided, you need to set an override. Note, that this may be broken. Example snippet of configuration.nix:

  nixpkgs.config.packageOverrides = pkgs: {
    steam = pkgs.steam.override {
      nativeOnly = true;
    };
  };
  programs.steam.enable = true;

FHS environment only (aka GOG/Humble)

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 GOG or HumbleBundle games.

First option is to install eithersteam-run or steam-run-native. The native version may work better for DRM-free standalone games.

Example snippet of configuration.nix:

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

unfree Other option, in case you need more flexibility, is to directly reference to the part of steam metapackage instead. In fact, steam-run-native above is just a wrapper linking to steam.run.

Example snippet of configuration.nix:

  environment.systemPackages = with pkgs; [
  (steam.override { nativeOnly = true; }).run
  ];

This builds same result as steam-run-native above.

Install the game by setting the executable attribute on the installer and then running it via steam-run ./your_gog_installer.sh. After installation, edit the "~/.local/share/applications/your_game_here.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

may also need nativeOnly = true; but i have not tested

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

Bumblebee and Primus

  environment.systemPackages = with pkgs; [
  (steam.override { withPrimus = true; extraPkgs = pkgs: [ bumblebee glxinfo ]; nativeOnly = true; }).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.

Limit user access

  users.users.<your-username>.packages = [
    pkgs.steam
  ];

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 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 param)

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.

Known issues

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

steam-run

steam-run 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 steam-run. Before trying other solutions, try starting your game this way, where start-game.sh is the script used to start the game on Linux.

 $ steam-run ./start-game.sh

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 configurations.