Help needed with nvidia config on gnome


continuing on my journey into NixOS, which I’m willing to have as my daily driver, I’m struggling to get my GPU running properly.

I followed the instructions here and I have no major issues, but the card doesn’t seem to work at it’s fullest.

When running Krita (my main working tool) it lags and jitters a bit. I enabled and disabled Canvas Graphics Acceleration there, and there’s a huge difference, so the GPU is doing something, but when enabled it still is a bit jerky.

While configuring Nvidia, I first tested it without Optimus PRIME with my Intel card disabled, and Krita ran smoothly framerate-wise as it did in my Arch system, but it was vary glitchy rendering it unusable.

Now I don’t have glitches, but it’s too laggy to work on it.

I have tried both Offload and Sync modes, although I’m not sure how to make krita run with offload. I tried this script but it makes no difference. I honestly don’t know how to properly use Offload (I am clueless on GPU speciffics).

May this have something to do with Gnome running on Wayland instead of X11?

I’m an illustrator, not a computer scientist, but I know more or less my way around. I’ve been using Arch for a couple of years as my only OS, but it’s a bit too on-the-edge and I’m looking for a more stable system. NixOS seems like a good way to go.

I’m on a Lenovo Thinkpad P53 running Nvidia Quadro RTX 3000.

Any idea on how to make it work faster and smoothly?

I have an nvidia card for gaming on one of my machines. Using xorg instead of wayland fixed jitters. It’s selectable at gnome login.

1 Like


I tried logging in to Gnome using Xorg but I get stuck in an endless loop in the login prompt, which only actually launches gnome if I set it to the default, which I assume is Wayland. Is there something else I need to change in configuration.nix?

Maybe you’re experiencing this issue:

I followed the workaround here: GNOME Session Crashes with Auto-Login · Issue #103746 · NixOS/nixpkgs · GitHub

…which ended up in my config for all my GUI-enabled machines here:

You can see the Nvidia machine’s config that references that one here:

1 Like

With the offload method all programs open with the integrated GPU by default, so to make them open with the dedicated Nvidia GPU you have to prefix them with the script. In this case it would be:

$ nvidia-offload krita

You can use the script from the article, or the one from the wiki and add it to your hardware-configuration.nix or the module where you’re configuring your nvidia settings:

{ config, lib, pkgs, modulesPath, ... }:

  nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export __VK_LAYER_NV_optimus=NVIDIA_only
    exec "$@"
  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

To make krita always open with nvidia-offload, you can create a local copy of its desktop file and modify its execution command:

$ cp /etc/profiles/per-user/user/share/applications/org.kde.krita.desktop ~/.local/share/applications/
$ sed 's/Exec=krita/Exec=nvidia-offload krita/' ~/.local/share/applications/org.kde.krita.desktop

Edit: For the glitches you might also want to try other versions of the driver as newer versions might offer better Wayland support.

Edit 2: Relevant issue:
Running krita with XWAYLAND_NO_GLAMOR=1 might reduce the jitters but it might also reduce performance. You might want to use X11 until it’s ported to Wayland.

Note: I’m also on Gnome (Wayland) with an Nvidia GPU (RTX 3060 mobile, driver v550.54.14), but I don’t see such jitters and I have no problems.

Thanks. I’m not using autologin, but I tried it anyways. It didn’t solve the problem.

Yes, that’s what I did. It makes a difference between using the script and not using it, but I don’t get the same performacne as I do with X11 on Arch.

I’m trying to figure out how to get Gnome working on X11, now. I checked journalctl and there’s a no screens found error. I’ve searched and all I’ve found is this thread, but they relate it to ZFS which I’m not using and they talk about solving with an upgrade, which I can’t do because I think I’m on the latest stable release.

Not sure how to proceed. Maybe I should just disregard Gnome and use KDE instead? I have used it in the past, but I wanted to give Gnome a try. I quite like it so far.

Assuming this is mainly a Gnome issue, you can apply the following patch which improves the performance a lot and see if the jitters and slowdowns are still there or not.

You can try KDE and see if the issue persists there to narrow down the scope a bit. You can also try to launch Gnome (X11) from another Display Manager (like sddm or lightdm) while you’re at it.

Would using a more recent kernel solve this, perhaps?

# /etc/nixos/configuration.nix
  boot.kernelPackages = pkgs.linuxPackages_latest;

If it doesn’t, the following entry in the Arch wiki leads me to believe that it could be an issue with the busID used to configure optimus, so you should double check that.

I think I finally solved it:

It was a bus ID problem indeed.

Reading the Arch wiki article made me think I may have miss-translated the bus ID number from hex to decimal. And that sure was the problem: I had translated Nvidia’s PCI bus number from pci@0000:01:00.0 to PCI:0:1:0 which was not correct. The correct ID is PCI:1:0:0.

This allowed me to log into Gnome with Xorg and Krita now runs as expected, fast and smooth without jitters nor glitches.

Thank you very much @codesupply and @eljamm for your very useful and kind help!

1 Like