Sway from Home-Manager?

Previously, I configured everything in configuration.nix. Now I am trying to configure as much as possible via home-manager. I would like to get Sway working with as little installed in configuration.nix as possible.

Here is a minimal home.nix that demonstrates the error message:

{ config, pkgs, ... }:
{
  programs.home-manager.enable = true;
  home.stateVersion = "20.03";
  wayland.windowManager.sway.enable = true;
}

And here is the error message I get when attempting to start sway:

MESA-LOADER: failed to open radeonsi (search paths /run/opengl-driver/lib/dri)
failed to load driver: radeonsi
MESA-LOADER: failed to open kms_swrast (search paths /run/opengl-driver/lib/dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast (search paths /run/opengl-driver/lib/dri)
failed to load swrast driver
2020-08-22 16:59:44 - [backend/drm/renderer.c:19] Failed to create GBM device
2020-08-22 16:59:44 - [backend/drm/backend.c:203] Failed to initialize renderer
2020-08-22 16:59:44 - [backend/backend.c:163] Failed to open DRM device 9
2020-08-22 16:59:44 - [backend/backend.c:304] Failed to open any DRM device
2020-08-22 16:59:44 - [sway/server.c:47] Unable to create backend

I verified that the amdgpu module is loaded:

$ lsmod | grep ^amdgpu
amdgpu               4689920  1

Other than boot.initrd.availableKernelModules = [ "amdgpu" ]; I haven’t put anything grapics related into configuration.nix and I am wondering if I am missing something. What should I try next?

Bonus question: right now wayland.windowManager.sway.xwayland = false; (the default) but eventually I will likely need to enable it. Will I be able to configure everything to run Xwayland via home-manager or will I need to add something to configuration.nix?

1 Like

Seems like you’re hitting MESA-LOADER: failed to open $driver · Issue #94315 · NixOS/nixpkgs · GitHub. MESA-LOADER: failed to open $driver · Issue #94315 · NixOS/nixpkgs · GitHub and the following comments/replies should be relevant. You can check by running export LIBGL_DEBUG=verbose before you start Sway or by adding that to programs.sway.extraSessionCommands.

I cannot reliably answer the home-manager part since I don’t use it, but AFAIK you should set programs.sway.enable for NixOS and can configure the rest through home-manager.

2 Likes

Thanks for the pointer @primeos. I added the following to configuration.nix per per MESA-LOADER: failed to open $driver · Issue #94315 · NixOS/nixpkgs · GitHub and rebuilt. Sway works now:

  hardware.opengl = {
    enable = true;
    driSupport = true;
  };
4 Likes