Steam: Difference between revisions

From NixOS Wiki
imported>Fadenb
No edit summary
imported>Fadenb
m Syntax highlighting
Line 3: Line 3:


== I want to play ==
== I want to play ==
For 64-bit systems it's important to have <code>hardware.opengl.driSupport32Bit = true</code> in your NixOS configuration. You'll also need <code>hardware.pulseaudio.support32Bit = true</code> if you are using PulseAudio - this will enable 32bit ALSA apps integration.
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.


== Master/Unstable branch ==
== Master/Unstable branch ==
Line 10: Line 10:
== Stable branch ==
== Stable branch ==
Install "steam" and "steamChrootEnv" packages. Run:
Install "steam" and "steamChrootEnv" packages. Run:
sudo init-steam-chrootenv
<syntaxhighlight lang="bash">
sudo mount-steam-chrootenv
sudo init-steam-chrootenv
load-steam-chrootenv
sudo mount-steam-chrootenv
steam
load-steam-chrootenv
steam
</syntaxhighlight>
To destroy the chroot env, run:
To destroy the chroot env, run:
sudo umount-steam-chrootenv
<syntaxhighlight lang="bash">
sudo destroy-steam-chrootenv
sudo umount-steam-chrootenv
sudo destroy-steam-chrootenv
</syntaxhighlight>


== Description of the package ==
== Description of the package ==
Line 53: Line 57:
=== But what about the games? ===
=== But what about the games? ===
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:
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:
  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)
<syntaxhighlight lang="bash">
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)
</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!
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!


Line 68: Line 74:
* 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
<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 param)
</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.
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.


=== Using the FOSS Radeon drivers ===
=== Using the FOSS Radeon drivers ===
The open source radeon drivers need a newer libc++ than is provided by the default runtime, which leads to acrash on launch. Use
The open source radeon drivers need a newer libc++ than is provided by the default runtime, which leads to acrash on launch. Use
 
<syntaxhighlight lang="nix">
(steamPackages.override { newLibcpp = true; }).steam-chrootenv
(steamPackages.override { newLibcpp = true; }).steam-chrootenv
</syntaxhighlight>
[https://github.com/NixOS/nixpkgs/pull/12404 in your config] if you get an error like
[https://github.com/NixOS/nixpkgs/pull/12404 in your config] if you get an error like


Line 85: Line 94:
=== Known issues ===
=== Known issues ===
# No java in steam chrootenv. Games affected: Towns:
# No java in steam chrootenv. Games affected: Towns:
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found
<syntaxhighlight lang="console">
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found
</syntaxhighlight>

Revision as of 12:56, 27 August 2017

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.

I want to play

For 64-bit systems it's important to have hardware.opengl.driSupport32Bit = true in your NixOS configuration. You'll also need hardware.pulseaudio.support32Bit = true if you are using PulseAudio - this will enable 32bit ALSA apps integration.

Master/Unstable branch

Install "steam" package. Run "steam". Many of the games will just work.

Stable branch

Install "steam" and "steamChrootEnv" packages. Run:

sudo init-steam-chrootenv
sudo mount-steam-chrootenv
load-steam-chrootenv
steam

To destroy the chroot env, run:

sudo umount-steam-chrootenv
sudo destroy-steam-chrootenv

Description of the package

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.

Nix problems and constraints

  • We don't have /bin/bash and many scripts point there. Similarly for /usr/bin/python, for some functionality.
  • We don't have the dynamic loader in /lib
  • 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

chroot

This is the current approach, documented here: http://sandervanderburg.blogspot.nl/2013/09/composing-fhs-compatible-chroot.html

  • Pros:
    • it would allow us to have binaries in the expected paths without disrupting the system
    • Steam itself, as well as Valve games and perhaps others like to checksum their executables, so patching does not work
  • Cons: performance?

Link bash to /bin and glibc/lib to /lib and be happy

  • Pros: easy, works
  • Cons: not very nix-compliant

Workaround the scripts and launch steam directly

  • Pros: not so hard
  • 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

This is the approach that I (page) took in my github branch: https://github.com/cpages/nixpkgs/tree/steam

Intercept Steam's calls with LD_PRELOAD or the like

  • Pros: more robust
  • Cons: difficult to achieve and may be broken by changes in the binary

aszlig started working in this in his branch: https://github.com/aszlig/nixpkgs/tree/steam

But what about the games?

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:

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)

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!


Troubleshooting

I was sure you would reach this part.

Steam fails to start. What do I do?

strace is your friend.

Game X 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.

Using the FOSS Radeon drivers

The open source radeon drivers need a newer libc++ than is provided by the default runtime, which leads to acrash on launch. Use

(steamPackages.override { newLibcpp = true; }).steam-chrootenv

in your config if you get an error like

libGL error: unable to load driver: radeonsi_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: radeonsi
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

Known issues

  1. No java in steam chrootenv. Games affected: Towns:
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found