Steam: Difference between revisions

imported>Dmarcoux
m Fix code in "Adding missing dependencies"
imported>SuperSamus
Initial cleanup (steam-native doesn't exist anymore, some redundant information removed)
Line 3: Line 3:
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.  


 
== Install ==
== Installation ==
Several installation options exist.
 
== Normal install ==


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 23: Line 19:
   ];
   ];
}
}
</syntaxHighlight>
=== 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 <code>configuration.nix</code>:
<syntaxHighlight lang=nix>
  nixpkgs.config.packageOverrides = pkgs: {
    steam = pkgs.steam.override {
      nativeOnly = true;
    };
  };
  programs.steam.enable = true;
</syntaxHighlight>
</syntaxHighlight>


Line 45: Line 29:
After that, steam-tui should start fine.
After that, steam-tui should start fine.


=== FHS environment only (aka GOG/Humble) ===
=== 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 GOG or HumbleBundle games.
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.


First option is to install either<syntaxhighlight lang="nix" inline>steam-run</syntaxhighlight> or <syntaxhighlight lang="nix" inline>steam-run-native</syntaxhighlight>. The native version may work better for DRM-free standalone games.
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>:
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
   ];
   ];
</syntaxHighlight>
</syntaxHighlight>


 
Another option, in case you need more flexibility, is to directly reference the part of steam metapackage.
Another option, in case you need more flexibility, is to directly reference the part of steam metapackage. 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 { /* Your overrides here */ }).run
   ];
   ];
</syntaxHighlight>
</syntaxHighlight>
This builds same result as <code>steam-run-native</code> above.


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


may also need <code>nativeOnly = true;</code> but i have not tested
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
   nixpkgs.config.packageOverrides = pkgs: {
   nixpkgs.config.packageOverrides = pkgs: {
Line 89: Line 72:
       withPrimus = true;
       withPrimus = true;
       extraPkgs = pkgs: [ bumblebee glxinfo ];
       extraPkgs = pkgs: [ bumblebee glxinfo ];
      nativeOnly = true;
     }).run
     }).run
   ];
   ];
Line 103: Line 85:


You can test java availability by invoking chrooted bash instance: <code>steam-run bash</code> and then typing: <code>java -version</code>. Can be combined with extra packages above.
You can test java availability by invoking chrooted bash instance: <code>steam-run bash</code> and then typing: <code>java -version</code>. Can be combined with extra packages above.
== Limit user access ==
<syntaxHighlight lang=nix>
  users.users.<your-username>.packages = [
    pkgs.steam
  ];
</syntaxHighlight>


== Troubleshooting ==
== Troubleshooting ==
Line 124: Line 99:
* 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.


=== Known issues ===
=== 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 <code>steam-run bash</code>.
"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>.


== steam-run ==
== Steam hardware ==
<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.
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.
<syntaxhighlight lang="commands">
$ steam-run ./start-game.sh
</syntaxhighlight>


== Steam hardware ==
Note that this is already enabled with <code>programs.steam.enable = true;</code>.
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:Applications]]
[[Category:Applications]]