Nvidia drivers not working

I have installed NixOS, and I love it. I configured everything, I tested everything, and I wanted to add Nvidia drivers. I followed instructions and I added these two lines to my config:

services.xserver.videoDrivers = [ “nvidia” ];

hardware.nvidia.modesetting.enable = true;

I also checked with lsmod and lspci and the kernel module and the GPU is detected. However when I boot up my system I see no X output. It stalls at “Starting target Graphical User Interface”. Another weird thing, as I tried to troubleshoot by going to console mode, I ran nvidia-smi as normal user and I got “No devices detected”. When I run it as root it works. I also checked that the nouveau driver is blacklisted. I am a bit confused on how to fix this. I am new to NixOS, sorry if this is a stupid question.

Have you checked out this wiki page? Depending on your hardware configuration you might need to try something special like Nvidia Prime.

If you’re using gdm you might try disabling wayland.

Thanks I will try this out. I will enable Nvidia Wayland for gdm. If this fix work, can I edit the wiki page to include this?