Closed Krutonium closed 2 years ago
For those interested, it's available in the NUR: https://github.com/nix-community/nur-combined/blob/master/repos/dukzcry/pkgs/gamescope.nix.
I can take care of porting the NUR derivation to nixpkgs and becoming the official maintainer. Just need a few weeks to understand the codebase a bit before committing to it.
I can take care of porting the NUR derivation to nixpkgs and becoming the official maintainer. Just need a few weeks to understand the codebase a bit before committing to it.
Are you still interested in doing that? Would love to see this in nixpkgs :)
I read on NixOS's discord that https://github.com/Plagman/gamescope/issues/380 is a blocker.
Yeah, that issue kinda upset me. I've been accompanying its progress but not being able to use controller for gamescope games suck. I do intend to free up some time to work on this. The NUR package was very oudated and not so well written at the time I checked it out, so I'd most likely would have to refactor it, which would take some effort.
@samueldr managed to package it for their project here. They opted to re-build the submodules using the Nix packages' srcs which should be remedied for inclusion into Nixpkgs.
Oh nice, that helps a lot.
I did it this way as a shortcut.
It would probably be best to have an "updater" script next to the derivation that builds a srcs.nix
attrset with the same exact source trees the git submodules point to. Though I haven't seen any weirdness, so I don't think that it would matter currently.
Of course, yes.
I think it'd be sufficient to make gamescope dependent on the output paths instead of the subproject build result; just like any other dependency.
Should gamescope require special versions of those dependencies in the future, we should be able to easily provide those.
Were you able to make gamescope work from within Steam (as in: /nix/store/blah-gamescope/bin/gamescope %command%
)? When I tried that, it was unable to find a free X11 socket for xwayland due to what seems like the bubblewrap container interfering with UIDs?
I've only used gamescope to run the new steamos interface, so games were in gamescope since steam itself was in gamescope. I haven ot tried any other kind of use.
I tested it nested (within X11) and directly off of KMS.
I've tried prepending games in steam with gamescope -e --
, but as Atemu said, thy don't run, failing with that exact error.
So I've tried running the games without steam, by going to their directories and running gamescope -- <game>
. That still didn't work (because of binary incompatibility), so I ran gamescope -- steam-run <game>
, which actually works outside of steam, but still fails inside.
If anyone knows how to debug this, I'd be happy to help.
Add gamescope -e -- %command%
in steam launch option.
Meant to say I also added the e
flag but forgot. It was there and still not working.
I tried gamescope
in various cases, here are the results:
on X: I can run commands/games through gamescope
on X: I failed to run steam games with gamescope (error message about /tmp/.X11-unix ownership)
on X: I failed to run lutris games with gamescope (same error as with steam)
on X: I can start steam or lutris in gamescope so the games inherits the environment, it's not practical at all
on wayland: same results than with X
on bare wayland without using a display manager: I can use gamescope with Lutris
on bare wayland without using a display manager: Steam games with gamescope in the launcher options are running, but no window are displayed...
tested with intel GPU and nvidia dedicated GPU on NixOS unstable
For the intel GPU, sometimes there are corruption in the image, using INTEL_DEBUG=noccs
environment variable solve this issue. This is tracked in gamescope repository issues.
I tried to use it in Steam by putting gamescope -e -- %command%
into a game's launch options, but it crashes with a segfault (see logs). I'm running an AMD Zen 3 CPU & RDNA2 GPU w/ RADV.
Check the stdout/err log, it's probably the xwayland issue.
I'm able to use the flatpak gamescope with few problems (doens't work well with the vanilla proton, but it works with the recent versions of proton-ge just fine apparently)
FWIW, I have to use the patch mentioned here to get it to work on the Intel chip (the Nvidia works fine without it though, in my optimus setup): https://github.com/Plagman/gamescope/issues/508#issuecomment-1201817413
Oh nice!
I tried to run the nixpkgs gamescope to open the 0ad game to test it out, and it failed on swaywm:
~ % gamescope -r 40 -U -f -- 0ad
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
vulkan: selecting physical device 'AMD RADV POLARIS10': queue family 1
vulkan: physical device does not support DRM format modifiers
vulkan: supported DRM formats for sampling usage:
vulkan: 0x34325241
vulkan: 0x34325258
vulkan: 0x3231564E
wlserver: [backend/headless/backend.c:82] Creating headless backend
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/server.c:92] Starting Xwayland on :1
wlserver: [xwayland/server.c:247] Xwayland startup failed, not setting up xwm
It's the xwayland issue as I suspected. I think we should have a separate issue on that.
I don't think that's our issue, there is an upstream issue as well as a PR to potentially address it: Plagman/gamescope#571
When I dug into this a while ago, it was due to it not being able to start its own xwayland session because a directory was owned by nobody rather than root or the current user inside our container IIRC.
When I dug into this a while ago, it was due to it not being able to start its own xwayland session because a directory was owned by nobody rather than root or the current user inside our container IIRC.
I'm hitting a problem when attempting to use the package that sounds similar. It attempts to use the /tmp/.X11-unix
socket, which is owned by the currently logged in user.
~ > ls -l /tmp/.X11-unix
total 0
srwxrwxrwx 1 ivv users 0 Aug 16 21:11 X0
Im a bit confused as to why this socket isnt owned by root in the first place, looking at some documentation from Xorgs release notes it seems like that is required:
The socket directories created in /tmp are now required to be owned by root and have their sticky-bit set. If the premissions are not set correctly, the component using this directory will print an error message and fail to start. Common socket directories that are known to be affected include:
/tmp/.font-unix
/tmp/.ICE-unix
/tmp/.X11-unix
These directories are used by the font server, xfs, applications using the Inter-Client Exchange protocol (ICE) and the X server, respectively.
This issue seems to stem from startx
(which I use) from what I can tell. Its nixos module explains that The X server runs under the user's id, not as root
, although I havent double checked if the issue occurs with other display managers. @Atemu are you also using startx
?
Log:
wlserver: [backend/headless/backend.c:82] Creating headless backend
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:99] /tmp/.X11-unix not owned by root or us
wlserver: [xwayland/sockets.c:216] No display available in the first 33
Afterwards it exits, so no games launch.
@IvarWithoutBones I use SDDM in combination with sway or i3.
Gdm with gnome wayland here. In my case /tmp/.X11-unix
is owned by root, and gamescope just exit with the same error.
After I made the current user the owner, gamescope made some progress, and but exit with the follow error:
wlserver: [backend/headless/backend.c:82] Creating headless backend
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/server.c:92] Starting Xwayland on :2
Xwayland: symbol lookup error: /nix/store/76pa9pv4fkwl68ybl3lphcyrrmwyx45j-libkrb5-1.20/lib/libcom_err.so.3: undefined symbol: k5_os_mutex_destroy, version krb5support_0_MIT
wlserver: [xwayland/server.c:247] Xwayland startup failed, not setting up xwm
Maybe it's xwayland's issue?
Gdm with gnome wayland here. In my case
/tmp/.X11-unix
is owned by root, and gamescope just exit with the same error. After I made the current user the owner, gamescope made some progress, and but exit with the follow error:wlserver: [backend/headless/backend.c:82] Creating headless backend wlserver: Running compositor on wayland display 'gamescope-0' wlserver: [backend/headless/backend.c:18] Starting headless backend wlserver: [xwayland/server.c:92] Starting Xwayland on :2 Xwayland: symbol lookup error: /nix/store/76pa9pv4fkwl68ybl3lphcyrrmwyx45j-libkrb5-1.20/lib/libcom_err.so.3: undefined symbol: k5_os_mutex_destroy, version krb5support_0_MIT wlserver: [xwayland/server.c:247] Xwayland startup failed, not setting up xwm
Maybe it's xwayland's issue?
Is kdr5
propagated into the environment? https://github.com/NixOS/nixpkgs/pull/83645 had a seemingly similar issue fixed with that. Might need to add it to steams chroot env if it isn't already.
Might want to give 3.11.43 a try
Also, I have an open PR to allow one to add a gamescope based steam session to your display manager, would appreciate it if some folks here could give it a review: https://github.com/NixOS/nixpkgs/pull/187507
After adding libkrb5
and keyutils
to steam, with 3.11.39, I tested several native and proton games, they all worked without any further issue.
@BillHuang2001 mind showing exactly how you did it?
Yes, the two packages are added in steam's extraPkgs.
nixpkgs.config.packageOverrides = pkgs: {
steam = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
];
};
};
And launch option in steam
gamescope -h 720 -H 1080 -U -f -- %command%
Are you running that in Xorg? I tried the same steps on Wayland and it still fails with the /tmp/.X11-unix not owned by root or us
errors.
I'm on wayland, you still have to manually run sudo chown <username> /tmp/.X11-unix
here. I don't know much about how wayland/xorg work, I have to manually set the owner every time after reboot.
After adding
libkrb5
andkeyutils
to steam, with 3.11.39, I tested several native and proton games, they all worked without any further issue.
FWIW this also works on sway. /tmp/.X11-unix
is owned by root, so that must be chowned first.
There must be something different, because I have launched gamescope in embedded mode, from a wayland session and from an X session, and I never had to chown anything
Same, nested (X11) and embedded (VT) worked on my end without anything wonky
Just in case, here's my groups:
users wheel audio video dialout adm networkmanager systemd-journal kvm
@BillHuang2001 I've tried your suggestion with extraPackages. Doesn't seem to work for me, even when chowning X11-lock:
GameAction [AppID 413150, ActionID 1] : LaunchApp changed task to Completed with ""
vulkan: selecting physical device 'AMD RADV RENOIR': queue family 1
vulkan: physical device supports DRM format modifiers
Fossilize INFO: Overriding serialization path: "/home/mihai/.local/share/Steam/steamapps/shadercache/413150/fozpipelinesv6/steamapprun_pipeline_cache".
vulkan: supported DRM formats for sampling usage:
vulkan: 0x34325241
vulkan: 0x34325258
vulkan: 0x3231564E
wlserver: [wayland] unable to lock lockfile /run/user/1000/gamescope-0.lock, maybe another compositor is running
wlserver: [wayland] unable to lock lockfile /run/user/1000/gamescope-1.lock, maybe another compositor is running
wlserver: Running compositor on wayland display 'gamescope-2'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/server.c:92] Starting Xwayland on :1
ERROR: ld.so: object '/home/mihai/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Xwayland: symbol lookup error: /nix/store/jqbgmjrf1466acvbfzs50yp51hkb1xdj-libkrb5-1.20/lib/libcom_err.so.3: undefined symbol: k5_os_mutex_destroy, version krb5support_0_MIT
wlserver: [xwayland/server.c:247] Xwayland startup failed, not setting up xwm
Installing breakpad exception handler for appid(steam)/version(1663887315)
I still get krb5 errors and the game doesn't show up, but steam reports it as running.
Perhaps I missed a step?
Config is here.
EDIT: My bad, I was using nixpkgs.config
but I was building my system with an explicit pkgs
pass. Moving the override in the pkgs
import solved the issue.
Sorry for necro-ing!
Using xorg & SDDM, and I do seem to have to sudo chown shados /tmp/.X11-unix
for gamescope launched from within Steam to work. But, that directory is owned by root on my system, so why doesn't it work? Quick check of what things look like within steam's FHS env namespace reveals the issue:
shados@dreamlogic[~] λ ls -lah /tmp/.X11-unix
total 42K
drwxrwxrwt 2 root root 3 Dec 21 00:25 .
drwxrwxrwt 18 root root 30 Dec 21 00:30 ..
srwxrwxrwx 1 root root 0 Dec 20 22:45 X0
shados@dreamlogic[~] λ steam-run ls -lah /tmp/.X11-unix
total 42K
drwxrwxrwt 2 nobody nogroup 3 Dec 21 00:25 .
drwxrwxrwt 18 nobody nogroup 30 Dec 21 00:30 ..
srwxrwxrwx 1 nobody nogroup 0 Dec 20 22:45 X0
shados@dreamlogic[~] λ sudo chown shados /tmp/.X11-unix
[sudo] password for shados:
shados@dreamlogic[~] λ steam-run ls -lah /tmp/.X11-unix
total 42K
drwxrwxrwt 2 shados nogroup 3 Dec 21 00:25 .
drwxrwxrwt 18 nobody nogroup 30 Dec 21 00:30 ..
srwxrwxrwx 1 nobody nogroup 0 Dec 20 22:45 X0
It appears that Steam's namespace maps all instances of users other than the current one in to nobody
, and this causes the issue. This is also why it works fine for me if I use it outside of Steam. This behaviour is coming from bubblewrap, which buildFHSUserEnv
uses under the hood, but I'm not sure how to fix this. I believe Flatpak also uses bubblewrap for sandboxing, so if this is working with Flatpak Steam, it may be worth taking a look at what it's doing...
gamescope does work in Flatpak Steam, I did some digging and what Flatpak is doing is mostly equivalent to passing
extraBwrapArgs = [
"--tmpfs /tmp/.X11-unix"
"--ro-bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0"
];
in steam-fhsenv
's call to buildFHSUserEnv
, but with some code to parse $DISPLAY
for the appropriate socket name instead of just assuming X0
, and some sanity checks on ensuring it actually exists to begin with. I don't think it's currently possible to replicate that code in nixpkgs; I think we'd need the ability to prepend some additional bash to buildFHSUserEnv
's bwrapCmd
.
Did anyone mange to get past this issue?
wlserver: [xwayland/server.c:108] Starting Xwayland on :1
ERROR: ld.so: object '/home/me/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Xwayland: symbol lookup error: /nix/store/lkbxlllgchqavfl6ldz60vx0p7gkzc08-libkrb5-1.20.1/lib/libcom_err.so.3: undefined symbol: k5_os_mutex_destroy, version krb5support_0_MIT
wlserver: [xwayland/server.c:270] Xwayland startup failed, not setting up xwm
Workaround:
The solution was a combination of multiple steps:
Disable MangoHud if used globally: programs.mangohud.enableSessionWide = false;
_(Alternatively it sounds like it's possible to bypass the segmentation fault with ENABLE_VKBASALT=1
https://github.com/flightlessmango/MangoHud/issues/822)_
Don't force Wayland since GameScope still uses XWayland. The biggest culprit seems to be SDL_VIDEODRIVER
, leaving it unset might be the best idea. Here's my envs on Hyprland:
{
wayland.windowManager.hyprland.xwayland.enable = true;
home-manager.users.me.home.sessionVariables = {
GDK_BACKEND = "wayland,x11";
QT_QPA_PLATFORM = "wayland;xcb";
#SDL_VIDEODRIVER = "x11";
CLUTTER_BACKEND = "wayland";
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
XDG_SESSION_DESKTOP = "Hyprland";
WLR_NO_HARDWARE_CURSORS = "1";
};
}
Fix undefined symbols in X11 session (Thanks @BillHuang2001):
{
environment.systemPackages = with pkgs; [ gamescope ];
nixpkgs.config.packageOverrides = pkgs: {
steam = pkgs.steam.override {
extraPkgs = pkgs: with pkgs; [
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
];
};
};
}
I was able to use GameScope with GameMode and MangoHud like this with my 3840x1600@120 display in Steam. Goto Steam > Game > Properties > Launch Options and add:
gamescope -W 3840 -H 1600 -r 119 -f -e -- mangohud gamemoderun %command%
Some minor issues that I've encountered with GameScope:
services.xserver.layout
?).I benchmarked GameScope versus running directly in Wayland with my configuration and I found the Wayland session to be noticeably smoother. Frametimes and FPS were slightly better in Hyprland/Wayland according to MangoHud with Xanmod 6.2 kernel and performance governor. I also found that GameScope performs a lot better when VRR is enabled and direct scanout is disabled: --adaptive-sync --force-composition
.
Hope this helps anyone!
Project description This is the Wayland based compositor that Valve is using, that when paired with a running application, can fix minimizing and other such issues, as well as allowing AMD FSR on any application.
Metadata