Graphical glitches with Nvidia drivers on NixOS


I have been using NixOS on my desktop PC for a few days, which has an Nvidia GTX 1060 6GB GPU. My CPU does not have integrated graphics. I’ve tried adding the following line to my configuration.nix to use the proprietary nvidia drivers:

services.xserver.videoDrivers = [ "nvidia" ];

When I reboot into the new system, I experience unbearable graphical glitches regularly from when Xorg starts. They can best be described as a rapid flickering effect in multiple applications such as emacs, terminal emulators and firefox. For instance when I try and change to a buffer in emacs or jump down a certain number of lines, the text will flicker very rapidly between the two states. Thumbnails and text in the GTK file picker will also do this and text in a terminal emulator will exhibit the same issue especially when clearing the output. I don’t seem to have these issues when I don’t specify the videoDrivers value. I thought that it might be partly due to one of my monitors having a refresh rate of 144Hz; when I set the refresh rates in software, the issue does seem to improve a bit but it still occurs, just less frequently. I’ve also tried other things like “force composition pipeline”, but the flickering always seems to happen eventually.

Apologies if this is considered more of a general Linux issue than a NixOS one, but I haven’t had any issues with nvidia drivers when using other linux distributions recently on this same PC, and general troubleshooting hasn’t helped.

I should add that I am on the unstable channel and the driver version is 450.66. Right now I am trying the “legacy” options for videoDrivers to see if that helps at all.

I have somewhat similar issues, generally this only comes apparent after it goes to a suspend state then wakes up.

But I believe the regressions are more from the kernel version, rather than the driver.

can you do:

  boot.kernelPackages = pkgs.linuxPackages_4_19;

in your /etc/nixos/configuration.nix and see if you’re still getting issues? (will need to do nixos-rebuild boot and restart)

Another less-invasive option would be sudo nvidia-settings then goto screen -> opengl settings -> allow flipping = off, but I get mixed results with this.

1 Like

Thank you for the advice, but it wasn’t to do with suspend/wake.

It seems to have been an obscure bug to do with the picom compositor, I probably would have figured that out sooner, but I was under the impression that I was still getting the glitches with picom disabled (it was actually still running)

I’m cautiously optimistic now that everything is fine and I can move on with enjoying NixOS!

1 Like

Can confirm, picom causes very strange behavior here as well, mostly flickering polybar, and chrome rendering only black after resuming from suspend. Haven’t tracked down what exactly it is though.