NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.6k stars 13.08k forks source link

`gamescope`: `bwrap: Can't chdir to /etc/nixos/desktop: No such file or directory` #293339

Open drakon64 opened 4 months ago

drakon64 commented 4 months ago

Describe the bug

Games or applications cannot be run from a Gamescope session. This causes the following error: bwrap: Can't chdir to /etc/nixos/desktop: No such file or directory

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run gamescope -e -- steam in a terminal
  2. Observe error

Expected behavior

Steam (or any other application) is launched within a Gamescope session.

Additional context

Running GNOME on Wayland, NixOS 23.11, NVIDIA proprietary drivers

Notify maintainers

@nrdxp @pedrohlc @Scrumplex @zhaofengli

Metadata

[adamc@nixos:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.7.6, NixOS, 23.11 (Tapir), 23.11.4976.79baff8812a0`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 4 months ago

what's PWD? are you running this command from your home dir?

drakon64 commented 4 months ago

what's PWD? are you running this command from your home dir?

Yes, from my home

Scrumplex commented 4 months ago

This is very odd. bwrap just uses pwd here. https://github.com/NixOS/nixpkgs/blob/b8697e57f10292a6165a20f03d2f42920dfaf973/pkgs/build-support/build-fhsenv-bubblewrap/default.nix#L214

eclairevoyant commented 4 months ago

what's PWD? are you running this command from your home dir?

Yes, from my home

There's no reason /etc/nixos/desktop should be involved in the error then :thinking:

Can you post your config?

SuperSandro2000 commented 4 months ago

looks like the same symptoms as https://github.com/nixos/nixpkgs/commit/63754031ca7ce6193c05f6a69205ba03c834c835

drakon64 commented 4 months ago

Can you post your config?

configuration.nix

{ config, pkgs, ... }:

{
  imports = [
    ./hardware-configuration.nix
    ./desktop/configuration.nix
    ./desktop/unstable.nix
  ];

  boot.loader = {
    efi.canTouchEfiVariables = true;
    systemd-boot.enable = true;
  };

  environment = {
    sessionVariables.NIXOS_OZONE_WL = "1";

    systemPackages = with pkgs; [
      discord
      ffmpeg
      jetbrains.idea-ultimate
      # r2modman
      webcord
      xivlauncher

      gnomeExtensions.alphabetical-app-grid
      gnomeExtensions.appindicator
      gnomeExtensions.dash-to-dock
      gnomeExtensions.gamemode-indicator-in-system-settings

      (wrapOBS {
        plugins = with obs-studio-plugins; [
          obs-pipewire-audio-capture
          obs-vkcapture
        ];
      })
    ];
  };

  hardware.opengl.driSupport32Bit = true;

  programs = {
    _1password-gui.enable = true;

    gamemode = {
      enable = true;

      settings.general = {
        renice = 20;
      };
    };

    steam = { 
      enable = true;
      gamescopeSession.enable = true;
    };
  };

  # services.openssh.enable = true;

  users.users.adamc = {
    description = "Adam Chance";
    extraGroups = [ "gamemode" "networkmanager" "wheel" ];
    isNormalUser = true;
  };
}

desktop/configuration.nix

{ config, lib, pkgs, ... }:

{
  networking.hostName = "nixos";

  networking.networkmanager.enable = true;

  time.timeZone = "Europe/London";

  i18n.defaultLocale = "en_GB.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_GB.UTF-8";
    LC_IDENTIFICATION = "en_GB.UTF-8";
    LC_MEASUREMENT = "en_GB.UTF-8";
    LC_MONETARY = "en_GB.UTF-8";
    LC_NAME = "en_GB.UTF-8";
    LC_NUMERIC = "en_GB.UTF-8";
    LC_PAPER = "en_GB.UTF-8";
    LC_TELEPHONE = "en_GB.UTF-8";
    LC_TIME = "en_GB.UTF-8";
  };

  services.xserver.enable = true;

  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  services.xserver = {
    layout = "gb";
    xkbVariant = "";
  };

  console.keyMap = "uk";

  sound.enable = true;
  hardware.pulseaudio.enable = lib.mkForce false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

  nixpkgs.config.allowUnfree = true;

  system.stateVersion = "23.11";

  boot = {
    kernelPackages = pkgs.linuxPackages_latest;
    supportedFilesystems = [ "bcachefs" ];
  };

  documentation.nixos.enable = false;

  environment = {
    gnome.excludePackages = with pkgs; [
      epiphany
      gnome.geary
      gnome.gnome-calendar
      gnome.gnome-characters
      gnome.gnome-clocks
      gnome.gnome-contacts
      gnome.gnome-font-viewer
      gnome.gnome-maps
      gnome.gnome-music
      gnome.simple-scan
      gnome-connections
      gnome-tour
      gnome.yelp
      snapshot
    ];

    systemPackages = with pkgs; [
      firefox
      vim
    ];
  };

  hardware.nvidia.modesetting.enable = true;

  nixpkgs.overlays = [(final: super: {
    zfs = super.zfs.overrideAttrs(_: {
      meta.platforms = [];
    });
  })];

  services.xserver = {
    excludePackages = [ pkgs.xterm ];
    videoDrivers = [ "nvidia" ];
  };
}

desktop/unstable.nix

{ config, pkgs, ... }:

let
  unstable = import
    (builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixos-unstable)
    { config = config.nixpkgs.config; };
in
{
  environment.systemPackages = with pkgs; [
    unstable.r2modman
    unstable.webcord
  ];
}

hardware-configuration.nix

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "UUID=70335a84-bdcb-4a88-a2ca-46c49e508946";
      fsType = "bcachefs";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/9921-36F9";
      fsType = "vfat";
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp6s0.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
drakon64 commented 4 months ago

Interestingly I can't replicate this anymore (Steam still doesn't work within Gamescope, but it's a separate issue).

However, I get this error when trying to launch Steam games with Gamescope added through the launch options (in this example, GTA V):

[adamc@desktop:~]$ steam
steam.sh[23138]: Running Steam on nixos 23.11 64-bit
steam.sh[23138]: STEAM_RUNTIME is enabled automatically
setup.sh[23216]: Steam runtime environment up-to-date!
steam-runtime-identify-library-abi: Failed to execute child process "/sbin/ldconfig" (No such file or directory)
run.sh[23228]: steam-runtime-identify-library-abi --ldconfig-paths failed, falling back to ldconfig
run.sh[23228]: Warning: An unexpected error occurred while executing "/sbin/ldconfig -XNv", the exit status was 127
steam.sh[23138]: Steam client's requirements are satisfied
tid(23254) burning pthread_key_t == 0 so we never use it
[2024-03-09 18:28:02] Startup - updater built Feb 29 2024 00:39:10
[2024-03-09 18:28:02] Startup - Steam Client launched with: '/home/adamc/.local/share/Steam/ubuntu12_32/steam'
03/09 18:28:02 Init: Installing breakpad exception handler for appid(steam)/version(1709168962)/tid(23254)
[2024-03-09 18:28:02] Loading cached metrics from disk (/home/adamc/.local/share/Steam/package/steam_client_metrics.bin)
[2024-03-09 18:28:02] Using the following download hosts for Public, Realm steamglobal
[2024-03-09 18:28:02] 1. https://client-update.akamai.steamstatic.com, /, Realm 'steamglobal', weight was 1000, source = 'update_hosts_cached.vdf'
[2024-03-09 18:28:02] 2. https://cdn.cloudflare.steamstatic.com, /client/, Realm 'steamglobal', weight was 1, source = 'update_hosts_cached.vdf'
[2024-03-09 18:28:02] 3. https://cdn.steamstatic.com, /client/, Realm 'steamglobal', weight was 1, source = 'baked in'
[2024-03-09 18:28:02] Verifying installation...
[2024-03-09 18:28:02] Verification complete
UpdateUI: skip show logo
Steam logging initialized: directory: /home/adamc/.local/share/Steam/logs

/nix/store/6jccsbgsxjvyydl25x2hx6hrfmyqd0wf-dconf-0.40.0-lib/lib/gio/modules/libdconfsettings.so: wrong ELF class: ELFCLASS64
Failed to load module: /nix/store/6jccsbgsxjvyydl25x2hx6hrfmyqd0wf-dconf-0.40.0-lib/lib/gio/modules/libdconfsettings.so
/nix/store/12f3im03452yq37baczijjxdwcb1nfxf-gvfs-1.52.2/lib/gio/modules/libgvfsdbus.so: wrong ELF class: ELFCLASS64
Failed to load module: /nix/store/12f3im03452yq37baczijjxdwcb1nfxf-gvfs-1.52.2/lib/gio/modules/libgvfsdbus.so
XRRGetOutputInfo Workaround: initialized with override: 0 real: 0xf048e7b0
XRRGetCrtcInfo Workaround: initialized with override: 0 real: 0xf048cfa0
steamwebhelper.sh[23261]: === Sat  9 Mar 18:28:03 GMT 2024 ===
steamwebhelper.sh[23261]: Starting steamwebhelper under bootstrap sniper steam runtime at /home/adamc/.local/share/Steam/ubuntu12_64/steam-runtime-sniper
CAppInfoCacheReadFromDiskThread took 111 milliseconds to initialize
Steam Runtime Launch Service: starting steam-runtime-launcher-service
Steam Runtime Launch Service: steam-runtime-launcher-service is running pid 23372
bus_name=com.steampowered.PressureVessel.LaunchAlongsideSteam
Vulkan missing requested extension 'VK_KHR_surface'.
Vulkan missing requested extension 'VK_KHR_xlib_surface'.
BInit - Unable to initialize Vulkan!
steamwebhelper.sh[23583]: === Sat  9 Mar 18:28:13 GMT 2024 ===
steamwebhelper.sh[23583]: Starting steamwebhelper under bootstrap sniper steam runtime at /home/adamc/.local/share/Steam/ubuntu12_64/steam-runtime-sniper
BRefreshApplicationsInLibrary 1: 1ms
BuildCompleteAppOverviewChange: 474 apps
RegisterForAppOverview 1: 9ms
RegisterForAppOverview 2: 10ms
x86_64-linux-gnu-capsule-capture-libs: warning: Dependencies of libnvidia-pkcs11.so.545.29.02 not found, ignoring: Missing dependencies: Could not find "libcrypto.so.1.1" in LD_LIBRARY_PATH "/home/adamc/.local/share/Steam/ubuntu12_32:/home/adamc/.local/share/Steam/ubuntu12_32/panorama:/lib64:/lib32:/steamrt/amd64/lib/x86_64-linux-gnu:/steamrt/amd64/lib:/steamrt/amd64/usr/lib/x86_64-linux-gnu:/steamrt/amd64/usr/lib:/steamrt/i386/lib/i386-linux-gnu:/steamrt/i386/lib:/steamrt/i386/usr/lib/i386-linux-gnu:/steamrt/i386/usr/lib:/run/opengl-driver/lib:/run/opengl-driver-32/lib", ld.so.cache, DT_RUNPATH or fallback /lib:/usr/lib
x86_64-linux-gnu-capsule-capture-libs: warning: Dependencies of libnvidia-pkcs11.so.545.29.02 not found, ignoring: Missing dependencies: Could not find "libcrypto.so.1.1" in LD_LIBRARY_PATH "/home/adamc/.local/share/Steam/ubuntu12_32:/home/adamc/.local/share/Steam/ubuntu12_32/panorama:/lib64:/lib32:/steamrt/amd64/lib/x86_64-linux-gnu:/steamrt/amd64/lib:/steamrt/amd64/usr/lib/x86_64-linux-gnu:/steamrt/amd64/usr/lib:/steamrt/i386/lib/i386-linux-gnu:/steamrt/i386/lib:/steamrt/i386/usr/lib/i386-linux-gnu:/steamrt/i386/usr/lib:/run/opengl-driver/lib:/run/opengl-driver-32/lib", ld.so.cache, DT_RUNPATH or fallback /lib:/usr/lib
x86_64-linux-gnu-capsule-capture-libs: warning: Dependencies of libnvidia-pkcs11.so.545.29.02 not found, ignoring: Missing dependencies: Could not find "libcrypto.so.1.1" in LD_LIBRARY_PATH "/home/adamc/.local/share/Steam/ubuntu12_32:/home/adamc/.local/share/Steam/ubuntu12_32/panorama:/lib64:/lib32:/steamrt/amd64/lib/x86_64-linux-gnu:/steamrt/amd64/lib:/steamrt/amd64/usr/lib/x86_64-linux-gnu:/steamrt/amd64/usr/lib:/steamrt/i386/lib/i386-linux-gnu:/steamrt/i386/lib:/steamrt/i386/usr/lib/i386-linux-gnu:/steamrt/i386/usr/lib:/run/opengl-driver/lib:/run/opengl-driver-32/lib", ld.so.cache, DT_RUNPATH or fallback /lib:/usr/lib
pressure-vessel-wrap[24583]: W: "/run/current-system/sw/bin/getent" is unlikely to appear in "/run/host"
pressure-vessel-wrap[24583]: W: Found more than one possible libdrm data directory from provider
/nix/store/6jccsbgsxjvyydl25x2hx6hrfmyqd0wf-dconf-0.40.0-lib/lib/gio/modules/libdconfsettings.so: undefined symbol: g_assertion_message_cmpint
Failed to load module: /nix/store/6jccsbgsxjvyydl25x2hx6hrfmyqd0wf-dconf-0.40.0-lib/lib/gio/modules/libdconfsettings.so
/nix/store/12f3im03452yq37baczijjxdwcb1nfxf-gvfs-1.52.2/lib/gvfs/libgvfscommon.so: undefined symbol: g_task_set_source_tag
Failed to load module: /nix/store/12f3im03452yq37baczijjxdwcb1nfxf-gvfs-1.52.2/lib/gio/modules/libgioremote-volume-monitor.so
/nix/store/12f3im03452yq37baczijjxdwcb1nfxf-gvfs-1.52.2/lib/gvfs/libgvfscommon.so: undefined symbol: g_task_set_source_tag
Failed to load module: /nix/store/12f3im03452yq37baczijjxdwcb1nfxf-gvfs-1.52.2/lib/gio/modules/libgvfsdbus.so
/nix/store/kh9ciwf6bmyy4hjfb65h1381b4x5vgb7-glib-networking-2.78.0/lib/gio/modules/libgiognomeproxy.so: undefined symbol: g_task_get_source_tag
Failed to load module: /nix/store/kh9ciwf6bmyy4hjfb65h1381b4x5vgb7-glib-networking-2.78.0/lib/gio/modules/libgiognomeproxy.so
/nix/store/kh9ciwf6bmyy4hjfb65h1381b4x5vgb7-glib-networking-2.78.0/lib/gio/modules/libgiolibproxy.so: undefined symbol: g_task_get_source_tag
Failed to load module: /nix/store/kh9ciwf6bmyy4hjfb65h1381b4x5vgb7-glib-networking-2.78.0/lib/gio/modules/libgiolibproxy.so
/nix/store/kh9ciwf6bmyy4hjfb65h1381b4x5vgb7-glib-networking-2.78.0/lib/gio/modules/libgiognutls.so: undefined symbol: g_source_set_static_name
Failed to load module: /nix/store/kh9ciwf6bmyy4hjfb65h1381b4x5vgb7-glib-networking-2.78.0/lib/gio/modules/libgiognutls.so
fsync: up and running.
Fossilize INFO: Setting autogroup scheduling.
/bin/sh\0-c\0gamescope -e -w 1920 -h 1080 -W 3840 -H 2160 -F nis -- /home/adamc/.local/share/Steam/ubuntu12_32/reaper SteamLaunch AppId=271590 -- /home/adamc/.local/share/Steam/ubuntu12_32/steam-launch-wrapper -- '/home/adamc/.local/share/Steam/steamapps/common/SteamLinuxRuntime_sniper'/_v2-entry-point --verb=waitforexitandrun -- '/home/adamc/.local/share/Steam/steamapps/common/Proton - Experimental'/proton waitforexitandrun  '/home/adamc/.local/share/Steam/steamapps/common/Grand Theft Auto V/PlayGTAV.exe'\0
chdir "/home/adamc/.local/share/Steam/steamapps/common/Grand Theft Auto V"
ERROR: ld.so: object '/home/adamc/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/adamc/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/adamc/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/adamc/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
wlserver: [backend/headless/backend.c:68] Creating headless backend
vulkan: selecting physical device 'NVIDIA GeForce RTX 3090': queue family 2
vulkan: physical device supports DRM format modifiers
Fossilize INFO: Overriding serialization path: "/home/adamc/.local/share/Steam/steamapps/shadercache/271590/fozpipelinesv6/steamapprun_pipeline_cache".
vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x3231564E (VkResult: 0)
vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x38344241 (VkResult: 0)
vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x38344258 (VkResult: 0)
vulkan: supported DRM formats for sampling usage:
vulkan:   AR24 (0x34325241)
vulkan:   XR24 (0x34325258)
vulkan:   AB24 (0x34324241)
vulkan:   XB24 (0x34324258)
vulkan:   AB4H (0x48344241)
vulkan:   XB4H (0x48344258)
vulkan:   AB30 (0x30334241)
vulkan:   XB30 (0x30334258)
vulkan:   AR30 (0x30335241)
vulkan:   XR30 (0x30335258)
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:16] Starting headless backend
wlserver: [xwayland/server.c:108] Starting Xwayland on :2
ERROR: ld.so: object '/home/adamc/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Xwayland: symbol lookup error: /nix/store/51vn1p2ifxbxl0y833n5xj77akn7snia-libkrb5-1.20.2/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

Launch options: gamescope -e --expose-wayland -w 1920 -h 1080 -W 3840 -H 2160 -F nis -- %command%

drakon64 commented 4 months ago

Seems to be same same issue as https://github.com/NixOS/nixpkgs/issues/214275

nrdxp commented 4 months ago

Have you tried with gamescope.enable instead of steam.gamescopeSession?

The latter is meant to launch gamescope has a full window manager/compositor with steam as the sole executable, where you seem to want to use it inside an alternate/existing compositor to be launched within steam.

eclairevoyant commented 4 months ago

Have you tried with gamescope.enable instead of steam.gamescopeSession?

The latter enables the former: https://github.com/NixOS/nixpkgs/blob/nixos-23.11/nixos/modules/programs/steam.nix#L128

What you could try is running steam-gamescope directly, as some of the args are slightly different from what you wrote above.