NixOS 26.04 with legacy NVIDIA driver and Wayland: fails to start

Hi!

I updated my system the other day to NixOS 26.04 (actually, I’m on unstable so I just updated nixpkgs) and now my display manager (SDDM) fails to start. The system has a NVIDIA Quadro P2000 which is always a bit annoying to work with in Linux (requires the legacy 580 driver) but usually does the job.

Looking at the output of journalctl --boot=-1, I find the following:

long journalctl output
Mai 11 12:23:04 <hostname> kernel: [drm] Initialized nvidia-drm 0.0.0 for 0000:01:00.0 on minor 2
Mai 11 12:23:04 <hostname> kernel: Console: switching to colour dummy device 80x25
Mai 11 12:23:04 <hostname> kernel: nvidia 0000:01:00.0: vgaarb: deactivate vga console
Mai 11 12:23:04 <hostname> kernel: fbcon: nvidia-drmdrmfb (fb0) is primary device
Mai 11 12:23:04 <hostname> kernel: Console: switching to colour frame buffer device 160x45
Mai 11 12:23:04 <hostname> kernel: nvidia 0000:01:00.0: [drm] fb0: nvidia-drmdrmfb frame buffer device
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "Failed to gain real time thread priority (See CAP_SYS_NICE in the capabilities(7) man page). error: Die Operation ist nicht erlaubt\n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "Failed to gain real time thread priority (See CAP_SYS_NICE in the capabilities(7) man page). error: Die Operation ist nicht erlaubt\n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_wayland_drm: Failed to open drm device /dev/dri/card0\nkwin_wayland_drm: Failed to open drm device \n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_core: Failed to open /dev/dri/renderD129 device (No such device)\nkwin_wayland_drm: Failed to open drm device /dev/dri/renderD129\n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_wayland_drm: Received unexpected add udev event for: \"/dev/dri/card2\"\n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_wayland_drm: Failed to open drm device \n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_wayland_drm: Failed to open drm device \n"
Mai 11 12:23:04 <hostname> wireplumber[2082]: default: Failed to get percentage from UPower: org.freedesktop.DBus.Error.NameHasNoOwner
Mai 11 12:23:04 <hostname> wireplumber[2082]: spa.bluez5: BlueZ system service is not available
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_wayland_drm: Failed to open drm device \n"
Mai 11 12:23:04 <hostname> wireplumber[2082]: [0:00:15.598660460] [2082]  INFO IPAManager ipa_manager.cpp:147 libcamera is not installed. Adding '/nix/store/src/ipa' to the IPA search path
Mai 11 12:23:04 <hostname> wireplumber[2082]: [0:00:15.599932479] [2082]  INFO Camera camera_manager.cpp:340 libcamera v0.7.0
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_wayland_drm: Failed to open drm device \n"
Mai 11 12:23:04 <hostname> sddm-helper-start-wayland[2036]: "kwin_scene_opengl: 0x500: GL_INVALID_ENUM error generated. Invalid <face>.\nkwin_scene_opengl: Invalid framebuffer status:  \"GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\"\n"
Mai 11 12:23:04 <hostname> kernel: BUG: kernel NULL pointer dereference, address: 0000000000000028
Mai 11 12:23:04 <hostname> kernel: #PF: supervisor read access in kernel mode
Mai 11 12:23:04 <hostname> kernel: #PF: error_code(0x0000) - not-present page
Mai 11 12:23:04 <hostname> kernel: PGD 15e0b0067 P4D 15e0b0067 PUD 0
Mai 11 12:23:04 <hostname> kernel: Oops: Oops: 0000 [#1] SMP NOPTI
Mai 11 12:23:04 <hostname> kernel: CPU: 9 UID: 175 PID: 2037 Comm: .kwin_wayland-w Tainted: P           O        6.18.26 #1-NixOS PREEMPT(lazy)
Mai 11 12:23:04 <hostname> kernel: Tainted: [P]=PROPRIETARY_MODULE, [O]=OOT_MODULE
Mai 11 12:23:04 <hostname> kernel: Hardware name: HP HP Elite Tower 800 G9 Desktop PC/894D, BIOS U01 Ver. 02.20.00 11/12/2025
Mai 11 12:23:04 <hostname> kernel: RIP: 0010:_nv000582kms+0x4/0x10 [nvidia_modeset]
Mai 11 12:23:04 <hostname> kernel: Code: 87 50 01 00 00 60 0b 97 c3 48 c7 87 38 01 00 00 b0 09 97 c3 48 c7 87 40 01 00 00 80 0d 97 c3 c3 66 0f 1f 44 00 00 f3 0f 1e fa <0f> b6 47 28 c3 0f 1f 80 00 00 00 00 89 c9 48 8d 04 49 48 c1 e0 04
Mai 11 12:23:04 <hostname> kernel: RSP: 0018:ffffd0fac781fbb0 EFLAGS: 00010206
Mai 11 12:23:04 <hostname> kernel: RAX: ffffffffc39711a0 RBX: ffff8a0103bff500 RCX: 0000040000000000
Mai 11 12:23:04 <hostname> kernel: RDX: 0000000000000000 RSI: ffff8a0109980922 RDI: 0000000000000000
Mai 11 12:23:04 <hostname> kernel: RBP: ffffd0fac781fbe0 R08: ffff8a010338c1d8 R09: 0000000000000000
Mai 11 12:23:04 <hostname> kernel: R10: ffff8a0109980948 R11: ffffd0fac781fb08 R12: 0000000000000000
Mai 11 12:23:04 <hostname> kernel: R13: ffff8a0103bff508 R14: 0000000000000000 R15: 0000000000000000
Mai 11 12:23:04 <hostname> kernel: FS:  00007440e1b5ed00(0000) GS:ffff8a04df1c1000(0000) knlGS:0000000000000000
Mai 11 12:23:04 <hostname> kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Mai 11 12:23:04 <hostname> kernel: CR2: 0000000000000028 CR3: 000000013c67d003 CR4: 0000000000f72ef0
Mai 11 12:23:04 <hostname> kernel: PKRU: 55555554
Mai 11 12:23:04 <hostname> kernel: Call Trace:
Mai 11 12:23:04 <hostname> kernel:  <TASK>
Mai 11 12:23:04 <hostname> kernel:  nv_drm_framebuffer_create+0x20c/0x450 [nvidia_drm]
Mai 11 12:23:04 <hostname> kernel:  drm_internal_framebuffer_create+0x426/0x5a0
Mai 11 12:23:04 <hostname> kernel:  ? __pfx_drm_mode_addfb2_ioctl+0x10/0x10
Mai 11 12:23:04 <hostname> kernel:  drm_mode_addfb2+0x47/0x110
Mai 11 12:23:04 <hostname> kernel:  drm_ioctl_kernel+0xae/0x100
Mai 11 12:23:04 <hostname> kernel:  drm_ioctl+0x27e/0x590
Mai 11 12:23:04 <hostname> kernel:  ? __pfx_drm_mode_addfb2_ioctl+0x10/0x10
Mai 11 12:23:04 <hostname> kernel:  __x64_sys_ioctl+0x97/0xe0
Mai 11 12:23:04 <hostname> kernel:  do_syscall_64+0xd4/0x7c0
Mai 11 12:23:04 <hostname> kernel:  ? __do_sys_getpid+0x1d/0x30
Mai 11 12:23:04 <hostname> kernel:  ? do_syscall_64+0x10e/0x7c0
Mai 11 12:23:04 <hostname> kernel:  ? irqtime_account_irq+0x3c/0xc0
Mai 11 12:23:04 <hostname> kernel:  ? handle_softirqs+0x192/0x2a0
Mai 11 12:23:04 <hostname> kernel:  ? __irq_exit_rcu+0x4c/0xf0
Mai 11 12:23:04 <hostname> kernel:  entry_SYSCALL_64_after_hwframe+0x77/0x7f

I found the following pull request (#498612) that introduced a bunch of changes to the way the NVIDIA driver is set up. I changed my configuration accordingly:

{  
  hardware.nvidia = {
    # Since nixos 26.04 this is no longer needed:
    # package = config.boot.kernelPackages.nvidiaPackages.legacy_580;
    # Instead, we just use the branch:
    branch = "legacy_580";
    modesetting.enable = true;
    powerManagement.enable = true;
    open = false;
    nvidiaSettings = true;
  };
}

But my system still fails with the same error.

I had similar problems a while back when I was still using Arch Linux and found that by adding the nvidia, nvidia_modeset, nvidia_uvm and nvidia_drm kernel modules to the boot configuration can fix this issue (see Arch Wiki → NVIDIA → Early loading).
I added the following to my config and got everything working again:

{
  boot.kernelModules = [
    "nvidia"
    "nvidia_modeset"
    "nvidia_uvm"
    "nvidia_drm"
  ];
}

I don’t fully understand how the changes made to the NVIDIA driver configuration in 26.04 might have messed up my config. Before the changes, my old hardware.nvidia configuration was enough to get a running system, but now I need to add the kernel modules.

services.xserver.videoDrivers = [“nvidia”] is still required to enable most of the nvidia nixos module, including the boot.kernelModules option you mentioned. But that was the case before this refactor so you probably removed it by accident if it worked before.

Ah yes, this line is also in my config. I omitted it because I didn’t think its important. But it’s still there and also was there for the old config.