Skip to content

steam: fix proton versions with pressure-vessel - #114024

Merged
lovesegfault merged 10 commits into
NixOS:masterfrom
LuigiPiucco:pressure-vessel
Feb 23, 2021
Merged

lovesegfault merged 10 commits into
NixOS:masterfrom
LuigiPiucco:pressure-vessel

Conversation

@LuigiPiucco

@LuigiPiucco LuigiPiucco commented Feb 22, 2021 •

Copy link
Copy Markdown
Contributor
Motivation for this change

As detailed in #100655, Proton 5.13 and onward, due to the addition of pressure-vessel, stopped working on NixOS. pressure-vessel implements its own wrapping and distribution logic, and assumes an FHS-compatible environment all across its inner workings. As such, the old way we wrapped Steam was no longer enough. It's still backwards compatible, to allow older Proton to work (maybe some optimization could be done with the knowledge learned here, though). This PR's purpose is to get newer Proton working, hopefully to the same extent it works on other typical FHS distributions.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

  • Tested various 64 and 32 bit games on nvidia (@LuigiPiucco) and amdgpu (@ashkitten);
  • Used official (5.13 and Experimental) and unofficial (GE 5.21 and GE 6.1) Proton versions;
Additional details

A key component of how pressure-vessel works is ld.so.cache. Since neither NixOS nor our Steam bwrap provided one, it failed in multiple ways to find libraries. A cache was added to the bwrapping expression, along with a change to merge share folders of 32 and 64 bit packages, preferring 64 bit for conflicting files. This was to bring things like ICDs for both architectures. Environment variables and a few libraries were added to Steam's bwrap, and so were the system's graphics drivers. To this end, the programs.steam module was complemented, to add a version of Steam with appropriate drivers to systemPackages. As such, it is best to add Steam through programs.steam.enable = true, not by making it system-wide yourself.

Possible improvements to this PR include trying to find a better way to pass the system's drivers in a way that pressure-vessel will find them, allowing steam to be added and work without activating the module, and checking documentation to see if already points to programs.steam.

Fixes #100655.
Fixes #106571.
Fixes #103547

moben and others added 8 commits February 22, 2021 14:35
Preserve top-level symlinks such as /lib -> /usr/lib.

This allows nested containers such as Steam's new runtime to remount
/usr if they need to and then run unmodified binaries that reference
e.g. /lib/ld-linux-x86-64.so.2

Before, we would mount the fully resolved host directory at /lib and
thus the dynamic loader would always be the one from the host filesystem.
@ofborg ofborg Bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: steam Steam game store/launcher (store.steampowered.com) 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Feb 22, 2021
@fabianhjr

Copy link
Copy Markdown
Member

Have been using this patches for weeks now, thanks a lot @LuigiPiucco <3

@afontaine

afontaine commented Feb 22, 2021 •

Copy link
Copy Markdown
Contributor

I am hoping to actually test the changes out as well, but this is the nix-review output

Result of nixpkgs-review pr 114024 run on x86_64-linux 1

45 packages built:
  • Sylk
  • android-studio (androidStudioPackages.stable)
  • androidStudioPackages.beta
  • androidStudioPackages.canary
  • androidStudioPackages.dev
  • anki-bin
  • apple-music-electron
  • chrysalis
  • deltachat-electron
  • devdocs-desktop
  • electronplayer
  • irccloud
  • joplin-desktop
  • keeweb
  • kodiPlugins.steam-launcher
  • ledger-live-desktop
  • lens
  • lunar-client
  • lutris
  • lutris-free
  • marktext
  • minetime
  • molotov
  • mycrypto
  • notable
  • nuclear
  • p3x-onenote
  • plexamp
  • protontricks
  • radicle-upstream
  • rambox-pro
  • runwayml
  • ssb-patchwork
  • standardnotes
  • station
  • steam
  • steam-run
  • steam-run-native
  • steamcmd
  • timeular
  • trezor-suite
  • tusk
  • unityhub
  • wootility
  • zettlr

@L-as

L-as commented Feb 22, 2021

Copy link
Copy Markdown
Member

This works great for me, tried Mordhau with an AMD GPU on i3 using Proton Experimental in Steam.

@lovesegfault

Copy link
Copy Markdown
Member

Result of nixpkgs-review pr 114024 run on x86_64-linux 1

45 packages built:
  • Sylk
  • android-studio (androidStudioPackages.stable)
  • androidStudioPackages.beta
  • androidStudioPackages.canary
  • androidStudioPackages.dev
  • anki-bin
  • apple-music-electron
  • chrysalis
  • deltachat-electron
  • devdocs-desktop
  • electronplayer
  • irccloud
  • joplin-desktop
  • keeweb
  • kodiPlugins.steam-launcher
  • ledger-live-desktop
  • lens
  • lunar-client
  • lutris
  • lutris-free
  • marktext
  • minetime
  • molotov
  • mycrypto
  • notable
  • nuclear
  • p3x-onenote
  • plexamp
  • protontricks
  • radicle-upstream
  • rambox-pro
  • runwayml
  • ssb-patchwork
  • standardnotes
  • station
  • steam
  • steam-run
  • steam-run-native
  • steamcmd
  • timeular
  • trezor-suite
  • tusk
  • unityhub
  • wootility
  • zettlr

@lovesegfault

Copy link
Copy Markdown
Member

This looks good to me, I imagine @jonringer will want a look before merge though

@davidak

davidak commented Feb 23, 2021

Copy link
Copy Markdown
Member

Works also for me. AMD GPU using Proton 5.13-6.

Thanks!

@ashkitten

Copy link
Copy Markdown
Contributor

this supersedes #102178

@Atemu Atemu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! The games I play on Steam all work flawlessly.

SteamVR isn't reacting to the presence sensor or the base stations existence but that also happens when I revert the patches; I'll have to test that after the next reboot.
I also noticed this PR fixes #92795, thank you!

I have some small comments and questions:

hardware.steam-hardware.enable = true;

environment.systemPackages = [ pkgs.steam ];
environment.systemPackages = [ steam steam.run ];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes to programs.steam are there to pass system graphics drivers down to Steam's expression, which in turn passes them to build-fhsuserenv-bubblewrap, adding them to the ld cache that will be created in the container. This is also the part I alluded to in

find a better way to pass the system's drivers in a way that pressure-vessel will find them, allowing steam to be added and work without activating the module

Plus, steam.run was added as a convenience, since to add that manually the user would have to replicate the logic of the module.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, they only slightly diverge, the closure cost is essentially a small wrapping script

Comment on lines +141 to +150
--tmpfs ${glibc}/etc \
--symlink /etc/ld.so.conf ${glibc}/etc/ld.so.conf \
--symlink /etc/ld.so.cache ${glibc}/etc/ld.so.cache \
--ro-bind ${glibc}/etc/rpc ${glibc}/etc/rpc \
--remount-ro ${glibc}/etc \
--tmpfs ${pkgsi686Linux.glibc}/etc \
--symlink /etc/ld.so.conf ${pkgsi686Linux.glibc}/etc/ld.so.conf \
--symlink /etc/ld.so.cache ${pkgsi686Linux.glibc}/etc/ld.so.cache \
--ro-bind ${pkgsi686Linux.glibc}/etc/rpc ${pkgsi686Linux.glibc}/etc/rpc \
--remount-ro ${pkgsi686Linux.glibc}/etc \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use some comments explaining why all these dirs is needed (for future reference)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will add them, like so:

# Our glibc will look for the cache in its own path in `/nix/store`.
# As such, we need a cache to exist there, because pressure-vessel
# depends on the existence of an ld cache. However, adding one
# globally proved to be a bad idea (see #100655), the solution we
# settled on being mounting one via bwrap.
# Also, the cache needs to go to both 32 and 64 bit glibcs, for games
# of both architectures to work.

@LuigiPiucco

Copy link
Copy Markdown
Contributor Author

SteamVR isn't reacting to the presence sensor or the base stations existence but that also happens when I revert the patches; I'll have to test that after the next reboot.

According to @smcv, due to being inside a bwrap container, pressure-vessel games can't rely on udev (see #100655 (comment)), having to do things the hard way and re-implement input logic. Since the devices they test the most with are official console-style controllers, things like flight sticks, VR gear, racing sim gear etc. are more likely to face problems.

@LuigiPiucco

Copy link
Copy Markdown
Contributor Author

Result of nixpkgs-review pr 114024 for 548d50d

46 packages built:
- Sylk
- android-studio
- androidStudioPackages.beta
- androidStudioPackages.canary
- androidStudioPackages.dev
- anki-bin
- apple-music-electron
- chrysalis
- deltachat-electron
- devdocs-desktop
- electronplayer
- irccloud
- joplin-desktop
- keeweb
- kodiPlugins.steam-launcher
- ledger-live-desktop
- lens
- lunar-client
- lutris
- lutris-free
- marktext
- minetime
- molotov
- mycrypto
- notable
- nuclear
- p3x-onenote
- plexamp
- protontricks
- radicle-upstream
- rambox rambox-pro
- runwayml
- ssb-patchwork
- standardnotes
- station
- steam
- steam-run
- steam-run-native
- steamcmd
- timeular
- trezor-suite
- tusk
- unityhub
- wootility
- zettlr

@Algram

Algram commented Feb 23, 2021

Copy link
Copy Markdown
Member

Works flawlessly with one exception: With the latest Proton all my games first start with the wrong size:
image

This did not happen before. Other than that I am super happy, everything just went super smooth.

@LuigiPiucco

Copy link
Copy Markdown
Contributor Author

With the latest Proton all my games first start with the wrong size

I had a similar problem, though less pervasive. I have an ultrawide monitor, and games that weren't previously configured to run on its resolution (mostly the ones I hadn't played yet) would start on regular 1080p, and Steam would lower my desktop resolution to match. After changing the settings in game, though, it went away. Have you tried that? Do the settings reset on relaunching the game or anything weird like that?

@Algram

Algram commented Feb 23, 2021

Copy link
Copy Markdown
Member

It seems to happen on every game start. Changing the resolution manually does not seem to help.

@starcraft66

Copy link
Copy Markdown
Member

I couldn't find the following in your config

I actually removed those because I saw programs.steam.enable = true; enable them, or so I thought. I put them back and it made no difference.

Plus, they all seem to be related to Steam's overlay, which, to my understanding, we don't have control over, other than enable/disable in Steam.

I tried disabling my steam overlay but it didn't change anything sadly.

I think you might have tried this, but is older proton also not working? 5.0 and downward, 5.9-GE-8-ST if you want to test with GloriousEggroll's version.

I tested all the way down to Proton 5.0 previously. I just tested and was able to run Modern Warfare 2 with Proton 4.11 and under actually. Looking at the change log, I suspect this is because proton 5.0 made DXVK the default for Direct3D 9 games (which MW2 probably is seeing as it came out in 2009) and that it used WINED3D before that (the game runs in proton 5.0 with PROTON_USE_WINED3D=1 but not any later proton version).

Also, just as a sanity check, do vulkaninfo and steam-run vulkan-info point to anything problematic?

Doesn't look like it, I just ran both and diff'd the output:

❯ diff vki1.txt vki2.txt
840c840
< 		budget = 7581990912 (0x1c3ec0000) (7.06 GiB)
---
> 		budget = 7594573824 (0x1c4ac0000) (7.07 GiB)

@smcv

smcv commented Mar 2, 2021

Copy link
Copy Markdown

Looking at the change log, I suspect this is because proton 5.0 made DXVK the default

In that case it's a problem with Vulkan, rather than a problem with the pressure-vessel containers. (Proton 5.0 didn't use those, they're new in 5.13.)

@starcraft66

Copy link
Copy Markdown
Member

For the record, I have no problem using vulkan outside of pressure-vessel, here's Dota 2 running the native linux binary with the rendering engine set to vulkan.

2021-03-02_12-23

@LuigiPiucco

Copy link
Copy Markdown
Contributor Author

This is a very strange issue, I'm not entirely sure how to tackle it. Doing some research, I didn't find anything pointing to the problem being game-specific, the only remark is that it's a D3D9 game, so maybe disabling newer APIs might change things? Plus, you said you tested other games as well, this probably won't help.

We could enable DXVK debug mode with DXVK_LOG_LEVEL=debug, and if that points nowhere, check with validation layers by adding vulkan-validation-layers to the Steam expression's extraLibraries and setting VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. To do so,

  1. Disable the programs.steam module;
  2. Enable opengl/dri and the things the module does;
  3. Override steam with the nvidia drivers and the validation layers;
  4. Add the overridden steam to environment.systemPackages;
  5. Add the above variable definition to the game command;

@LuigiPiucco

Copy link
Copy Markdown
Contributor Author

The missing ICD and automatic hardware.opengl.driSupport = true fixes are in my branch now, but I'll wait to open a PR, I really want to fix @starcraft66's issue. Also, it just occurred to me, did you test Proton 5.0, with DXVK, without my patches? Since the issue likely has to do with DXVK and vulkan, I'd like to make sure it really stops working because of this pull.

@starcraft66

Copy link
Copy Markdown
Member

@LuigiPiucco I updated my input with your nixpkgs and everything is working now, I can start Modern Warfare 2, Among Us, 100% Orange Juice (all games which I tested previously and didn't run because DXVK couldn't find the video adapter). I can only assume that the 32-bit Nvidia ICD files were to blame!

@starcraft66

Copy link
Copy Markdown
Member

I think it's safe to say that could could open a new PR to add those fixes in.

@Atemu

Atemu commented Mar 2, 2021

Copy link
Copy Markdown
Member

SteamVR isn't reacting to the presence sensor or the base stations existence but that also happens when I revert the patches; I'll have to test that after the next reboot.

After getting SteamVR to work with the Index, it does indeed work; hooray!

@LuigiPiucco

Copy link
Copy Markdown
Contributor Author

Wow, I wasn't expecting that, that's great. I just created the PR. #114884

lovesegfault added a commit that referenced this pull request Mar 3, 2021
steam: continuation of #114024 with missing edits
@jasonodoom

Copy link
Copy Markdown
Member

When will this be available in unstable?

@lovesegfault

Copy link
Copy Markdown
Member

When will this be available in unstable?

Should already be there: https://nixpk.gs/pr-tracker.html?pr=114024

@jonringer

Copy link
Copy Markdown
Contributor

@jasonodoom should already be available https://status.nixos.org/

nix-channel --update
sudo !!
nixos-rebuild switch

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/steam-doesnt-detect-nvidia-graphics-device-after-update/11957/2

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/build-a-yocto-rootfs-inside-nix/2643/23

lihop pushed a commit to lihop/nixpkgs that referenced this pull request Apr 8, 2021
@YellowOnion

Copy link
Copy Markdown
Contributor

Few issues I've noticed:

  • System tray is broken, for example Rockstar and EGS launcher the tray icons shows up in it's own window.
  • mouse cursor is default x cursor and not my gnome-shell one.
  • copy and paste does not work.

@hpfr

hpfr commented Apr 19, 2021

Copy link
Copy Markdown
Contributor

These sound like Steam on Xwayland or WINE issues, not NixOS issues. I would try reproducing them another GNOME distro or X11. In any case, I'm pretty sure they're unrelated to pressure-vessel and NixOS, but please create another issue if you think it's due to NixOS to avoid pinging everyone in this thread.

@fabianhjr

Copy link
Copy Markdown
Member

System tray issue is WINE related behaviour; It has behaved like that as far back as I remember on GNOME @YellowOnion.

@foolnotion

Copy link
Copy Markdown
Contributor

Actually, I am using i3 + lxqt (not gnome), and the system tray icon is broken for me too. It just happened after an update without any changes on my part.

@06kellyjac

06kellyjac commented Apr 20, 2021 •

Copy link
Copy Markdown
Member

Might be related:
I'm on i3 no DE and my steam tray icon is broken too when launching from rofi. If I launch from my terminal steam the icon shows up fine. It worked fine before
Clicking on the steam icon is still unthemed x11 look but IDK if it was ever different, I've not done that too often so I dont remember.

@bryanasdev000

Copy link
Copy Markdown
Contributor

Might be related:
I'm on i3 no DE and my steam tray icon is broken too when launching from rofi. If I launch from my terminal steam the icon shows up fine. It worked fine before
Clicking on the steam icon is still unthemed x11 look but IDK if it was ever different, I've not done that too often so I dont remember.

I do not think its related, steam icon is broken for a long time (check #87774).

I also use rofi here but with awesomewm, no icon launched by rofi or terminal.

Not sure about other launchers like Rockstar one, but like @hpfr said, its better to create a issue and map it from there.


export STEAM_RUNTIME=${if nativeOnly then "0" else "/steamrt"}

export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/intel_icd.x86_64.json:/usr/share/vulkan/icd.d/intel_icd.i686.json:/usr/share/vulkan/icd.d/lvp_icd.x86_64.json:/usr/share/vulkan/icd.d/lvp_icd.i686.json:/usr/share/vulkan/icd.d/nvidia_icd.json:/usr/share/vulkan/icd.d/nvidia_icd32.json:/usr/share/vulkan/icd.d/radeon_icd.x86_64.json:/usr/share/vulkan/icd.d/radeon_icd.i686.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This boke Dota2 Vulkan mode (native Linux game) for NixOS 21.05, see:

#108598 (comment)

Comment on lines +153 to +157
--tmpfs ${pkgsi686Linux.glibc}/etc \
--symlink /etc/ld.so.conf ${pkgsi686Linux.glibc}/etc/ld.so.conf \
--symlink /etc/ld.so.cache ${pkgsi686Linux.glibc}/etc/ld.so.cache \
--ro-bind ${pkgsi686Linux.glibc}/etc/rpc ${pkgsi686Linux.glibc}/etc/rpc \
--remount-ro ${pkgsi686Linux.glibc}/etc \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke fhsenv bubblewrap usage on non x86 systems.

❯ nix-build -A platformio --system aarch64-linux
error: i686 Linux package set can only be used with the x86 family.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is easy enough to work around via optionalString but there are further i686 deps in the builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: steam Steam game store/launcher (store.steampowered.com) 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet