XWayland on Hyperland woes

Greetings! (From my recent NixOS install)

I’ve been using home-manager and nix-darwin for a while and decided to take the plunge on my desktop and install NixOS. I have the gnome desktop running currently. In gnome, I can run xorg apps via XWayland, and my environmental variables seem to be correct.

gnome config:

  # Enable the X11 windowing system.
  services.xserver = {
    enable = true;
  };
  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
# via nix-shell -p xorg.xclock
[nix-shell:~]$ echo $DISPLAY  $WAYLAND_DISPLAY
:0  wayland-0

xclock, and Steam run just fine. Webcord installed via flatpak launches fine as well.

My issues started when I installed Hyprland.

I followed the wiki for Hyprland on NixOS and I am using home-manager to configure it as well.

programs = {
  hyprland = {
    enable = true;
    xwayland.enable = true;
  };
....
};

in Hyprland I get:

# via nix-shell -p xorg.xclock
[nix-shell:~]$ echo $DISPLAY  $WAYLAND_DISPLAY
:0  wayland-1

and I get the error cannot open display :0 when I try to launch xclock or Steam.

I’ve checked my home-manager config for Hyprland and the config file is basically standard except for setting my monitors, changing some keybinds. I even commented out anything that was setting an env var just in case but I am still at a loss here with XWayland and trying to figure out what is setting wayland-1 in Hyprland but not Gnome.

Has anyone seen anything similar before? I am running nixos-unstable with Hyprland installed just via nixpkgs.

Additional information:

When xdg-desktop-portal fails to load which seems to happen on Hyprland if you kill the session and restart it, xclock runs just fine. (I didn’t bother trying Steam).

I am not adding any more portals via the xdg.portal option in either home-manager or my configuration.nix. I tried both but didn’t seem to have any luck.

I’m on Hyprland and I don’t have any issues with Steam or webcord. I do use the Hyprland flake (running main branch) though if that makes a difference. Maybe this is the relevant part of my config for you: nix-config/modules/nixos/userland.nix at afe54805970296ef55eb2a379d5f1bf4e86c04ba · aos/nix-config · GitHub

FWIW, this is echo:

$ echo $DISPLAY $WAYLAND_DISPLAY
:0 wayland-1

Thanks, I’ll just mimic your config when I get home. I see you’re just using the standard hyprland.conf and as far as I can see you’re not using the hone-manager module? Maybe I did something funky with home-manager. I’ve tried a few combos of xwayland.enable = true; in both, just configuration, just hm but had no luck.

I might also try tossing the qtwayland packages you have in there and just in general cleaning up my config to see if I’m double declaring something that’s upsetting the setup.

In general, I try to keep my configs outside of HM. My HM is pretty bare-bones (as you can see). I’d rather use the configuration syntax of the package vs. attempt to use HM modules that may or may not have the program available and/or the setting there. Just personal preference I guess.

Interesting. So I started out thinking, “there’s no way it’s the flake” and copying some of the packages you have, but I still couldn’t launch X11 apps.

I then enabled the flake for Hyprland in first the system package then and home-manager, and still nothing. (actually I was fine on just system package but enabling the home-manager module broke X11)

I even installed greetd in case that was somehow setting things up correctly for you.

Not using home manager works. I have no idea why. The minute I enable the home manager module I can’t launch X11 apps anymore. My config was so simple:

  wayland.windowManager.hyprland = {
    enable = true;
    # systemd.enable = false # I tried this too, idk
    xwayland.enable = true; # I even tried false here
    # this is from trying the flake but I tried standard pkgs first
    package = hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
    extraConfig = ''
      ${builtins.readFile ./hypr/hyprland.conf}
    '';
  };

Again, I think the system package and home-manager package are supposed to work together, but in the end doing this worked for me:

  home.file.".config/hypr/hyprland.conf".source = ./hypr/hyprland.conf;

Which I guess was all I was doing with the config I had anyway…

What revision of Nixpkgs were you using with home-manager? If it’s not the same one that was used to deploy your system (specifically: the graphics drivers), you’re likely to run into issues. Always keep the two instances of Nixpkgs the same.

I’m using unstable for both.

I updated both flakes, and also tried using the Hyprland flake for both system and home-manager.

You need to ensure that it’s the same revision of unstable too. The hyperland flake’s nixpkgs input must also be this same revision.

flake.lock for both my system and home-manager contain this exact nixpkgs:

    "nixpkgs": {
      "locked": {
        "lastModified": 1726937504,
        "narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "9357f4f23713673f310988025d9dc261c20e70c6",
        "type": "github"

I don’t think the revision was the issue. I was thinking I had something else set up wrong in my home-manager config but just turning off wayland.windowManager.hyprland.enable = true and using home.file to set my config fixed it.

1 Like