Change:
services.udev.extraRules = '' # Create /dev/nvidia-uvm when the nvidia-uvm module is loaded. <del> KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'" KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-modeset c 195 254'" KERNEL=="card*", SUBSYSTEM=="drm", DRIVERS=="nvidia", PROGRAM="${pkgs.gnugrep}/bin/grep 'Device Minor:' /proc/driver/nvidia/gpus/%b/information",  RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia%c{3} c 195 %c{3}" </del> <ins> KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c $$(grep nvidia-frontend /proc/devices | cut -d   -f 1) 255'" KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'for i in $$(cat /proc/driver/nvidia/gpus/*/information | grep Minor | cut -d   -f 4); do mknod -m 666 /dev/nvidia$${i} c $$(grep nvidia-frontend /proc/devices | cut -d   -f 1) $${i}; done'" KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-modeset c $$(grep nvidia-frontend /proc/devices | cut -d   -f 1) 254'" </ins> KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm c $$(grep nvidia-uvm /proc/devices | cut -d   -f 1) 0'" KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm-tools c $$(grep nvidia-uvm /proc/devices | cut -d   -f 1) 1'" '' + optionalString cfg.powerManagement.finegrained (

Discussion:
This is on latest nixos unstable
Same issues here. Every time I plug / unplug DP port, It appears and crash my GDM. I found this line in hardware - nvidia NixOS module:
I've got some cleanup commit(s): ctrl-f "nvidia". I've got a lot of cleanups in progress. I still have flickering (I think it's a sway issue) but no crashing and actually, I somehow fixed EGL+Xwayland. I'm not sure what you're experiencing though -- at least, I can't imagine why a failing udev rule would just cause gnome to crash. For the most part these rules seem to be setting permission on hotPLUG rather than unplug. But, I just got it to quiet down, I didn't investigate super thoroughly.
I also have these warnings when I boot and log into GDM: ( some whitespace for better reading) <details<preMay 23 15:10:09 copper systemd-udevd[688]: nvidia: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidiactl c 195 255'' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0-DP-1: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1.

May 23 15:10:10 copper systemd-udevd[688]: card0-HDMI-A-1: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0-DP-2: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0-DP-3: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1.

May 23 15:10:10 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0-Unknown-1: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:10 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:11 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1.

May 23 15:10:11 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:12 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. May 23 15:10:12 copper systemd-udevd[688]: card0: Process '/nix/store/14lypyys4gfcl982rjddxa6jg7msqz9q-bash-5.1-p16/bin/bash -c 'mknod -m 666 /dev/nvidia0 c 195 0' failed with exit code 1. </pre</detailsNote that those , warnings are for the physical sockets on the back of the card which are not connected to any monitor. The is a USB-C socket. The connected sockets, and , do not generate a warning. Also note that the first line (beginning with ) is trying to create a different file. Aside from these warnings, I do not experience any stability or other graphical issues. My setup: X11, GNOME NVIDIA RTX 2060 SUPER Latest stable proprietary driver Latest unstable nixpkgs -
I cannot use the HDMI port on my laptop either. Last time I tried I was on different hardware, but it worked then and my machine (about 3 months ago) was almost the same hardware, just the smaller screen version. On unstable but I tried reverting to 22.05 to see if it would help; no dice. Either way, I get this in my log over and over again, and my system becomes laggy until I unplug the cable: Does anyone have a lead on this? Is this something we need to address or is it a driver issue?

I didn't see anyone else post the kernel error, but at least in my case it seems to possibly indicate a driver and/or kernel issue. However, the weird thing is, when GDM first loads up the HDMI screen does work, but then stops working as soon as I log in. If I disable GDM all together then it never works, not even in the linux virtual terminal, this leads me to believe that it might actually be something we need to fix. Also, if I run the command from the log manually I get . I may try some older NixOS releases just to see if they might work, I'll report back if so. edit 11 didn't work either (same message in log), which is really strange since I used to used my HDMI cable all the time back then (albeit on other hardware)
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
after some testing, I found that resolves the udev errors in the log. It didn't fully resolve my HDMI issues, but it did help. I was able to render retroarch to an external monitor via VKKHRdisplay, which I wasn't able to do previously. So that's definitely an improvement, and the system stalling repetitive erros are also gone. The PR does have a merge conflict but it's pretty simple to resolve, I just copy and pasted the line from the PR replacing the existing line in a fork of nixos-unstable to test and it worked well.
Could you elaborate, please? What is better and what isn't? For me, X crashes whenever I plug or unplug an external monitor. Is this fixed?
I don't use X so I'm not sure. I stil cannot use (wayland) with an external monitor, so something is still wrong since I was able to a few months ago. Like I mentioned, the main improvements are the fact that my system is no longer unresponsive when the HDMI cable is plugged in, and that I was at least able to use retroarch from a tty, which I wasn't before. The udev related errors are also all gone in the logs as well.
For the record, I cherry-picked the commit on top of 22.05 to test. Plugging external monitors in hybrid mode still crashes X11 on my Thinkpad P15.

This laptop is only usable in discrete GPU mode. Too bad, I was hoping this was related