Hyprland crashes when wayland.windowManager.hyprland.enable is used

Hello!

I am new to NixOS as of about 5 days ago. I have been able to successfully set up Hyprland by declaring it in my /etc/nixos/configuration.nix and simply downloading then sourcing my dotfiles using home.file = { "file".source = "path/to/file" } in my home-manager home.nix but I would like to declare Hyprland using Nix syntax instead. I have been having issues for about 3 days straight now trying to get this working and I’ve narrowed it down to this one option

Any time I use wayland.windowManager.hyprland.enable = true; then log out and try to log back in, it crashes and gives me the same log. I have initialized a brand new set of home-manager files and changed the bare minimum to get hyprland enabled and it still fails. Here is what I have so far…

flake.nix

{
  description = "Home Manager configuration";

  inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    hyprland.url = "github:hyprwm/Hyprland";
  };

  outputs = { nixpkgs, home-manager, hyprland, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      homeConfigurations."home" = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;

        # Specify your home configuration modules here, for example,
        # the path to your home.nix.
        modules = [ 
          hyprland.homeManagerModules.default
          ./home.nix
          ];
      };
    };
}

home.nix

{ config, pkgs, ... }:


{
  home.username = "user";
  home.homeDirectory = "/home/user";

  home.packages = [
    pkgs.dconf
    pkgs.xdg-desktop-portal-hyprland
    pkgs.wayland
  ];

  home.file = {
  };

  home.sessionVariables = {
  };


  wayland.windowManager.hyprland = {
    enable = true;
    xwayland.enable = true;
    wayland.windowManager.hyprland.extraConfig = '' <my config> '';
  };

  programs.home-manager.enable = true;
}

configuration.nix has…

{ inputs, config, lib, pkgs, ... }:
{
... blah blah ....
# nvidia config
  hardware.nvidia = {
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };
  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.nvidia.modesetting.enable = true;
  boot.initrd.kernelModules = [ "nvidia" ];

# greetd & tuigreet
  services.greetd = {
    enable = true;
    settings = {
      default_session = {
        command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --remember --remember-session --cmd Hyprland";
        user = "greeter";
      };
    };
  };

  # environment variables
  environment.sessionVariables = {
    WLR_NO_HARDWARE_CURSORS = "1";
    NIXOS_OZONE_WL = "1";
    VK_DRIVER_FILES = "/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json";
    GTK_THEME = "Adwaita-dark";
   };

  programs.hyprland = {
    enable = true;
  };

yet if I remove wayland.windowManager.hyprland.enable = true; from my home.nix and leave hyprland installed only through my /etc/nixos/configuration.nix and use the following format to declare my configs it works just fine…

{ config, pkgs, ... }:

{

    home.file = {
    
# autostart configuration
    ".config/hypr/config/autostart.conf".text = ''
    ###########################
    ###      AUTOSTART      ###
    ###########################

    # default app launches
    exec-once = exec feh --bg-scale $(cat ~/.fehbg | cut -d ' ' -f 3-)
    exec-once = hyprpaper
    exec-once = dunst
    exec-once = systemctl --user start plasma-polkit-agent
    exec-once = waybar
    exec-once = swww-daemon
    exec-once = nm-applet
    exec-once = blueman-applet

    # fix electron apps
    #exec-once = LIBVA_DRIVER_NAME=i915 vdesktop --ignore-gpu-blocklist --disable-features=UseOzonePlatform --enable-features=VaapiVideoDecoder --use-gl=desktop --enable-gpu-rasterization --enable-zero-copy
    '';

  };

}

And here is the crash report:

--------------------------------------------
   Hyprland Crash Report
--------------------------------------------
I don't feel so good...

Hyprland received signal 11(SEGV)
Version: ceef4fb3a5efe1617790f56e2701846a21c2533d
Tag: 
Date: 2024-12-05
Flags:

System info:
System name: Linux
Node name: hobbiton
Release: 6.6.63
Version: #1-NixOS SMP PREEMPT_DYNAMIC Fri Nov 22 14:38:37 UTC 2024

GPU:
00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics] [8086:46a6] (rev 0c) (prog-if 00 [VGA controller])


os-release:
ANSI_COLOR="1;34"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
BUILD_ID="24.05.6835.0c5b4ecbed5b"
DOCUMENTATION_URL="https://nixos.org/learn.html"
HOME_URL="https://nixos.org/"
ID=nixos
IMAGE_ID=""
IMAGE_VERSION=""
LOGO="nix-snowflake"
NAME=NixOS
PRETTY_NAME="NixOS 24.05 (Uakari)"
SUPPORT_END="2024-12-31"
SUPPORT_URL="https://nixos.org/community.html"
VERSION="24.05 (Uakari)"
VERSION_CODENAME=uakari
VERSION_ID="24.05"
Backtrace:
# | /home/hobbit/.nix-profile/bin/Hyprland(_Z12getBacktracev+0x46) [0x6a3b56]
getBacktrace()
??:?
#1 | /home/hobbit/.nix-profile/bin/Hyprland(_ZN13CrashReporter18createAndSaveCrashEi+0xb84) [0x5d51a4]
CrashReporter::createAndSaveCrash(int)
??:?
#2 | /home/hobbit/.nix-profile/bin/Hyprland(_Z25handleUnrecoverableSignali+0x5f) [0x517e8f]
handleUnrecoverableSignal(int)
??:?
#3 | /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6(+0x40620) [0x7fa9f8160620]
??
??:0
#4 | /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6(+0x16aadd) [0x7fa9f828aadd]
??
??:0
#5 | /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6(__strdup+0x12) [0x7fa9f81c7ff2]
??
??:0
#6 | /nix/store/yi3i9rkcxdl13ks9rjsp63b226bx1rkc-mesa-24.0.7-drivers/lib/libEGL_mesa.so.0(+0x25aca) [0x7fa9e8618aca]
??
??:0
#7 | /nix/store/yi3i9rkcxdl13ks9rjsp63b226bx1rkc-mesa-24.0.7-drivers/lib/libEGL_mesa.so.0(+0x1d900) [0x7fa9e8610900]
??
??:0
#8 | /nix/store/yi3i9rkcxdl13ks9rjsp63b226bx1rkc-mesa-24.0.7-drivers/lib/libEGL_mesa.so.0(+0xf4a8) [0x7fa9e86024a8]
??
??:0
#9 | /nix/store/rg36s5s1f0vwyr7sqh5c11vdabn7xiqg-aquamarine-0.5.0+date=2024-11-18_4468981/lib/libaquamarine.so.4(_ZN10Aquamarine12CDRMRenderer7attemptEN9Hyprutils6Memory14CSharedPointerINS_13CGBMAllocatorEEENS3_INS_8CBackendEEE+0x611) [0x7fa9f9399381]
??
??:0
#1 | /nix/store/rg36s5s1f0vwyr7sqh5c11vdabn7xiqg-aquamarine-0.5.0+date=2024-11-18_4468981/lib/libaquamarine.so.4(_ZN10Aquamarine11CDRMBackend7onReadyEv+0x7b2) [0x7fa9f9361d82]
??
??:0
#11 | /nix/store/rg36s5s1f0vwyr7sqh5c11vdabn7xiqg-aquamarine-0.5.0+date=2024-11-18_4468981/lib/libaquamarine.so.4(_ZN10Aquamarine8CBackend5startEv+0x676) [0x7fa9f93269b6]
??
??:0
#12 | /home/hobbit/.nix-profile/bin/Hyprland(_ZN11CCompositor10initServerENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x301) [0x533801]
CCompositor::initServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)
??:?
#13 | /home/hobbit/.nix-profile/bin/Hyprland(main+0xc4f) [0x6fcfef]
main
??:?
#14 | /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6(+0x2a27e) [0x7fa9f814a27e]
??
??:0
#15 | /nix/store/pacbfvpzqz2mksby36awvbcn051zcji3-glibc-2.40-36/lib/libc.so.6(__libc_start_main+0x89) [0x7fa9f814a339]
??
??:0
#16 | /home/hobbit/.nix-profile/bin/Hyprland(_start+0x25) [0x4d9165]
_start
??:?

Log tail:
[LOG] [AQ] drm: Explicit sync supported
[LOG] [AQ] drm: connector eDP-1 crtc supports CTM
[LOG] [AQ] drm: Scanning connector id 245
[LOG] [AQ] drm: Connector id 245 already initialized
[LOG] [AQ] drm: Connector 245 connection state: 2
[LOG] [AQ] drm: Scanning connector id 257
[LOG] [AQ] drm: Connector id 257 already initialized
[LOG] [AQ] drm: Connector 257 connection state: 2
[LOG] [AQ] drm: Scanning connector id 263
[LOG] [AQ] drm: Connector id 263 already initialized
[LOG] [AQ] drm: Connector 263 connection state: 2
[LOG] [AQ] drm: Scanning connector id 272
[LOG] [AQ] drm: Connector id 272 already initialized
[LOG] [AQ] drm: Connector 272 connection state: 2
[LOG] [AQ] drm: Scanning connector id 281
[LOG] [AQ] drm: Connector id 281 already initialized
[LOG] [AQ] drm: Connector 281 connection state: 2
[LOG] [AQ] drm: Scanning connector id 291
[LOG] [AQ] drm: Connector id 291 already initialized
[LOG] [AQ] drm: Connector 291 connection state: 2
[LOG] [AQ] drm: Scanning connector id 293
[LOG] [AQ] drm: Connector id 293 already initialized
[LOG] [AQ] drm: Connector 293 connection state: 1
[LOG] [AQ] drm: Connector DP-6 connected
[LOG] [AQ] drm: Connecting connector DP-6, CRTC ID 131
[LOG] [AQ] drm: Dumping detected modes:
[LOG] [AQ] drm: Mode 0: 3840x1080@119.97Hz  (preferred)
[LOG] [AQ] drm: Mode 1: 5120x1440@100.00Hz 
[LOG] [AQ] drm: Mode 2: 5120x1440@59.98Hz 
[LOG] [AQ] drm: Mode 3: 3840x1080@99.96Hz 
[LOG] [AQ] drm: Mode 4: 3840x1080@59.97Hz 
[LOG] [AQ] drm: Mode 5: 2560x1440@59.95Hz 
[LOG] [AQ] drm: Mode 6: 2560x1080@120.00Hz 
[LOG] [AQ] drm: Mode 7: 2560x1080@119.88Hz 
[LOG] [AQ] drm: Mode 8: 2560x1080@100.00Hz 
[LOG] [AQ] drm: Mode 9: 2560x1080@60.00Hz 
[LOG] [AQ] drm: Mode 10: 2560x1080@60.00Hz 
[LOG] [AQ] drm: Mode 11: 2560x1080@59.94Hz 
[LOG] [AQ] drm: Mode 12: 1920x1080@120.00Hz 
[LOG] [AQ] drm: Mode 13: 1920x1080@119.88Hz 
[LOG] [AQ] drm: Mode 14: 1920x1080@100.00Hz 
[LOG] [AQ] drm: Mode 15: 1920x1080@60.00Hz 
[LOG] [AQ] drm: Mode 16: 1920x1080@60.00Hz 
[LOG] [AQ] drm: Mode 17: 1920x1080@59.94Hz 
[LOG] [AQ] drm: Mode 18: 1680x1050@59.95Hz 
[LOG] [AQ] drm: Mode 19: 1600x900@60.00Hz 
[LOG] [AQ] drm: Mode 20: 1280x1024@75.03Hz 
[LOG] [AQ] drm: Mode 21: 1280x1024@60.02Hz 
[LOG] [AQ] drm: Mode 22: 1440x900@59.89Hz 
[LOG] [AQ] drm: Mode 23: 1280x800@59.81Hz 
[LOG] [AQ] drm: Mode 24: 1152x864@75.00Hz 
[LOG] [AQ] drm: Mode 25: 1280x720@60.00Hz 
[LOG] [AQ] drm: Mode 26: 1280x720@59.94Hz 
[LOG] [AQ] drm: Mode 27: 1024x768@75.03Hz 
[LOG] [AQ] drm: Mode 28: 1024x768@70.07Hz 
[LOG] [AQ] drm: Mode 29: 1024x768@60.00Hz 
[LOG] [AQ] drm: Mode 30: 832x624@74.55Hz 
[LOG] [AQ] drm: Mode 31: 800x600@75.00Hz 
[LOG] [AQ] drm: Mode 32: 800x600@72.19Hz 
[LOG] [AQ] drm: Mode 33: 800x600@60.32Hz 
[LOG] [AQ] drm: Mode 34: 800x600@56.25Hz 
[LOG] [AQ] drm: Mode 35: 640x480@75.00Hz 
[LOG] [AQ] drm: Mode 36: 640x480@72.81Hz 
[LOG] [AQ] drm: Mode 37: 640x480@66.67Hz 
[LOG] [AQ] drm: Mode 38: 640x480@60.00Hz 
[LOG] [AQ] drm: Mode 39: 640x480@59.94Hz 
[LOG] [AQ] drm: Mode 40: 720x400@70.08Hz 
[LOG] [AQ] drm: Physical size [Vector2D: x: 1190, y: 340] (mm)
[LOG] [AQ] drm: Description Samsung Electric Company C49RG9x H1AK500000 (DP-6)
[LOG] [AQ] drm: connector DP-6 crtc is incapable of vrr: props.vrr_capable -> 0, crtc->props.vrr_enabled -> 24
[LOG] [AQ] drm: Explicit sync supported
[LOG] [AQ] drm: connector DP-6 crtc supports CTM
[LOG] [AQ] drm: Scanning connector id 295
[LOG] [AQ] drm: Connector id 295 already initialized
[LOG] [AQ] drm: Connector 295 connection state: 2
[LOG] [AQ] drm: gpu /dev/dri/card2 becomes primary drm
[LOG] [AQ] DRM Dumb: created a dumb allocator
[LOG] [AQ] Starting the Aquamarine backend!
[LOG] [AQ] Starting the Wayland backend!
[ERR] [AQ] Wayland backend cannot start: wl_display_connect failed (is a wayland compositor running?)
[ERR] [AQ] Requested backend (wayland) could not start, enabling fallbacks
[ERR] [AQ] Implementation wayland failed, erasing.
[LOG] [AQ] Created a GBM allocator with drm fd 41
[LOG] [AQ] drm: Connectors size2 9
[LOG] [AQ] Created a GBM allocator with drm fd 45

Things I have tried

  • declaring env = AQ_DRM_DEVICES to force GPU or Integrated GPU usage
  • enable/disable xwayland, systemd, systemd.enableXdgAutostart,
  • tried using home-manager nixos syntax, also tried just using hyprland.extraConfig to write my config as is
  • tried installing Hyprland through my home.nix and through my hyprland.nix
  • writing entire config in my hyprland.nix file instead of splitting it up into sub-modules
  • double checked I have nvidia modesetting and drm turned on
  • install Hyprland via configuration.nix instead of home.nix, this results in Hyprland logging in successfully but with the default hyprland.conf
  • install Hyprland via home.nix instead of configuration.nix, this results in crashes again
  • enabling/disabling LIBVA_DRIVER_NAME and __GLX_VENDOR_LIBRARY_NAME in my enviroment variables

System Information:

Dell XPS 15 9520
i7-12700H (with integrated graphics)
Nvidia RTX 3050 Mobile
Kernel 6.6.63

Any help would be appreciated.

You’re supposed to use the programs.hyprland.enable option to toggle if Hyprland is enabled or not.

NixOS wiki for Hyprland

1 Like

@thefossguy I do have that enabled in my /etc/nixos/configuration.nix at the bottom here…

Is it supposed to be in my home.nix instead?

Nope, in your configuration.nix file that is for NixOS.

this came down to a misunderstanding on how flakes work. Essentially, I was loading my config with no flakes with nixos-rebuild and building home-manager separately with home-manager switch --flake #<name>.

After reviewing the same documents over and over I realized my mistake. pulled my configuration,nix and hardware-configuration.nix into the same folder as my flake and built it all with nixos-rebuild switch --flake .#<name> and it works as expected now.