Launching steam games with gamescope and mangohud

buildFHSUserEnvBubbleWrap takes an argument extraBwrapArgs, but steam-fhsenv doesn’t seem to provide a way to add in that argument with an override, I’m afraid. So I’m not sure there’s an override-style method to get that changed, unless overrideAttrs works differently on this code than I think.

I believe that I need to create bug report somewhere

I’ve been having the exact same issue when trying out the gamescope integration in Bottles (on unstable). Using the built-in integration leads to the not owned by root or us issue.

Doing a simple invocation like this works just fine.

gamescope -f -- bottles-cli run -b some-bottle -p 'Some Game'

At the very least, Bottles does use buildFHSUserEnvBubblewrap more directly, so it might be possible to override and test there? This is all a little advanced for me, so I’m not 100% sure how to approach this myself.

1 Like

Yet it is still bug in nix that affect other software. For example in discord I can share application but I can’t share my screen. The rest of the people will seen black screen

Dig you create a bug report somewhere? I would love to follow it if so, although haven’t seen any in my googling

No, I still didn’t find the time. Sorry

I run into a different error when I try this now: instead of /tmp/.X11-unix not owned by root or us, I get Failed to bind socket @/tmp/.X11-unix/X0: Address already in use. It gets a bit further and then hangs.

wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:16] Starting headless backend
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X0: Address already in use
wlserver: [xwayland/server.c:108] Starting Xwayland on :1
ERROR: ld.so: object '/home/aidan/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Xwayland: symbol lookup error: /nix/store/zl98vicy04kkjq7lqqa8k75w1j8malck-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

You weren’t kidding when you said it’s a mess. I’m running this in an X session, so why is Xwayland even entering the picture?

For context, what I am trying to do is upscale run an old Windows game that runs normally under Steam Proton without gamescope, by changing the game “Launch Options” in Steam to

gamescope -h 480 -H 1440 %command%
1 Like

Gamescope is a wayland compositor (i.e. it is wayland), and can also run as a (nested) client on other wayland compositors and X11. As a client, it mostly forces whatever runs inside of it to behave as a proper window by wrapping it. If you’re running a game inside of it, that game will end up using xwayland 99.99% of the time.

Most of its supposed performance benefits only apply if you run it as a full session, so have no underlying X11/wayland, just like valve do on their OS.

It looks to me like you’re using a binary you downloaded from somewhere random. You’d need to patchelf it to work, or just use the actual NixOS package for gamescope.

Oh, oops! I had it the wrong way around in my head and thought it was an X server.

I’m running nixpkgs gamescope, added to the Steam FHS environment like this,

programs.steam = {
  enable = true;
  package = pkgs.steam.override {
    extraPkgs = pkgs: with pkgs; [
      gamescope
    ];
  };
};

Ah, so that’s how you bypassed the permissions problem.

Unfortunately afaik steam is bundled with a very wide array of libraries and injects them with LD_PRELOAD (valve don’t like supporting distro-provided libraries and need to mess with things for games to work anyway because game devs certainly don’t care), looks like mixing a nix store binary messes up the chain of which libraries are used where a bit.

Have you tried setting the steam support flag? It may at least work around the overlay bug. I think it’s -e.

I just tried adding that flag, and I get exactly the same output and behaviour as without it.

Indeed, this is a compelling setup! I’m just beginning to learn nix, so I took a shot at composing a stripped down configuration.nix using programs.steam.gamescopeSession by @nrdxp for launcing gamescope directly from a DM.

So far I’ve not yet gotten Steam working in any capacity without Gnome or KDE window management. Here’s what I’ve got:

{ config, pkgs, lib, ... }: {
  imports = [
    ./hardware-configuration.nix
  ];
  nixpkgs.config = {
    allowUnfreePredicate = pkg:
      builtins.elem (lib.getName pkg) [
        "nvidia-x11"
        "nvidia-settings"
        "nvidia-persistenced"
        "steam"
        "steam-original"
        "steam-run"
      ];
  };
  hardware = {
    nvidia.modesetting.enable = true;
    opengl = { # https://nixos.wiki/wiki/Nvidia
      enable = true;
      driSupport = true;
      driSupport32Bit = true;
    };
  };
  programs = {
    gamescope.enable = true;
    steam = {
      enable = true;
      gamescopeSession.enable = true;
    };
  };
  services.xserver = {
    enable = true;
    videoDrivers = ["nvidia"];
    displayManager = {
      gdm.enable = true;
    };
  };

  # basic nixos config follows
  boot.loader = {
    systemd-boot.enable = true;
    efi.canTouchEfiVariables = true;
  };
  users = {
    users = {
      root = {
        openssh.authorizedKeys.keyFiles = [
          /etc/nixos/ssh/authorized_keys
        ];
      };
      steam = {
        isNormalUser = true;
      };
    };
  };
  environment = {
    systemPackages = with pkgs; [
      psmisc
      rsync
    ];
  };
  networking = {
    hostName = "steambox";
    networkmanager.enable = true;
  };
  services.openssh.enable = true;
  system.stateVersion = "23.05";
}

Currently, it loads gdm and then hangs after logging in. I don’t know if I need to tell gdm to start the gamescopeSession or if I’m missing something else basic like that.

I’m running this on an RTX 1070, so nothing really fancy to do with prime or any of that. I found useful example in nrdos.

nvidia has all kinds of issues running wayland because nvidia refuse to implement a real mesa driver. Things have been getting better as they’ve slowly accepted that wayland is a thing now, but YMMV.

What do systemctl status display-manager, journalctl -t xsession, journalctl --user and dmesg give you after it hangs? I suspect it simply fails to start steam, you should be able to switch to a different tty (normally ctrl+alt+f1-12 except f7) to get logs.

2 Likes

tl;dr it’s actually a system hang now and keys won’t even work, so I’m giving up on gaming with Nvidia for awhile. I guess it’s only good for generating stable diffusion art now!

Indeed, I’ve noticed that HoloISO and ChimeraOS explicitly gave up on trying to support nvidia cards. I’ve observed quite a few crashes while trying to get the config to work with just Gnome and KDE. In a prior life, this machine was running on Steam on Arch for a good while. Now when I load in my old arch config it blows up the same way. Seems like things went downill fast with Nvidia.

Weirdly, the first time I installed Steam on Nix was on this machine using Gnome. I benchmarked Cyberpunk 2077 faster than I’d ever seen it run on Windows. It froze after I rebooted it and has been crashing since on either Arch or Nix. On further attempts to run the benchmark, it would crash mid-way through.

If they ever get their act together, we’ll have something pretty nice. Until then, there’s always AMD Radeon

Nah, as usual the FOSS community are doing the work, they just finally relented and decided to dump some undocumented source code.

2 Likes