Anyone else have major X11 and Nvidia problems from 26.05?

Hello everyone. I’ve been using NixOS for about nine months now, and overall I love the system - it took a lot of time to learn how to get it to work how I needed (particularly for audio stuff, which is my main focus) but I’ve enjoyed it quite a bit since I got it to that point. As I’ve seen other people say, “it takes a lot of work, but once you’ve got it set how you need, you’re golden”.

Until 26.05 came along at least, for me. My NixOS computer isn’t my main computer, it’s my secondary laptop, so I can go a little while without using it. I realized at some point recently that there was a new major version out, so I decided to work on getting it upgraded this weekend.

I learned from my last time struggling to get it to 25.11 that I needed to update the flake as well to make the main upgrade take effect, which was pretty much the only issue I ran into that time. This time there was a bit more.

A couple packages had been renamed so I just needed to fix those. But then we come across the first issue - the kernel version I use, rt_latest (realtime kernel for audio) was depreciated due to lack of maintenance. Now, this might not be a problem, I feel like I had heard about some of the improvements from the rt kernel being pulled into the upstream kernel, so maybe I didn’t need it. But it’s a bit concerning to me that it wasn’t depreciated for “merged into upstream” or something like that if that was the case, but rather just that it wasn’t being maintained any more.

Final build attempt after switching the kernel to just the normal latest one, and it all looks like it works!

Until I try logging in using X11.

This is a ThinkPad P43s, which has a discrete Nvidia Quadro P520 card in it. That had taken some time to get working in the first place when I was initially setting up the system, but it did work - however, it only worked in X11 as far as I could tell. I could open up nvidia-smi in X11 and see all the processes using it, looked totally fine. In Wayland, nvidia-smi never showed any processes (even when putting the computer under a relatively high graphical load), which implied to me that Wayland was just never using it.

So, I always used X11 with NixOS as a result. And when I tried logging in with X11 selected, it turns to a black screen, looks like it’s about to drop me on the desktop and then… back to SDDM. It’s like the display server has just ceased to be. Of course, nothing in my configuration regarding this had changed - all I had done was change the kernel and rename a couple renamed packages (and remove an unrelated package of my own). services.xserver.enable = true; is still there. And I don’t know if it’s just a result of search engines being borderline useless nowadays, but I couldn’t find anyone saying this happened to them. Looking at the current NixOS manual’s section on X, it seems like everything is in order.

Well, I log into Wayland. Figure I might as well run nvidia-smi, see if the upgrade worked out the kinks and now Wayland can use the card. But no, now nvidia-smi just doesn’t see a driver whatsoever. It doesn’t even start, just says there is no driver.

Well that’s not good. I do a bit of digging and find that apparently Nvidia drivers have just kind of been nonfunctional in Wayland this whole time? I don’t know if that’s true or not, but that could explain why it had never worked for me. But then in another thread of someone who seemed in a similar situation to me (though from years back IIRC), the recommendation was to use the legacy_### version of the driver for older cards, which the P520 most likely is. I looked up the latest driver version for it on Nvidia and it matched one of the legacy driver versions, so I switched it to that.

And it failed to build, because it was missing the “of_gpio.h” header. The only information I could find on this is that it may have just been removed outright? If so it has probably been replaced with a different header file but I’m not really at the level of, say, manually editing graphics card driver source code to change the header file it uses. But hey, nixos-hardware has a setup created for the P43s, so let me just remove my nvidia.nix file and let nixos-hardware handle it.

Same thing happened. Well, let me remove that from my flake and re-add my nvidia.nix file in case the flake had predominated it from the start.

Same thing, again. RIP.

~

So, unfortunately, I think this might have to be the end of the road for me and NixOS. It’s a shame, I really do like the system and “enjoyed” the challenge of getting it set up in the first place. I had it all working how I needed, it was great. The only thing I had left on my plate was to figure out how to get the Nvidia driver working with Wayland at some point, but I was in no rush for that. But 26.05 just messed it up. I’m sure my audio setup still works - assuming that not having the realtime kernel isn’t going to mess with it - but I don’t really want to limp along with a mutilated build with no working X11 and no working graphics card driver. (My theory is that X11 isn’t starting because it wants to start with the Nvidia driver, but can’t find it, so it just boots out back to sddm. So it might be possible to tell X11 to start with the integrated Intel driver, but that still doesn’t really fix the issue.)

While I do enjoy the challenge involved in getting things to work in Linux (a fun one recently was a tty-only Artix build using tmux as a sort of “display server” with a ton of TUI and CLI tools, links as a browser, cbonsai as a “desktop” decoration, etc), at the end of the day I do need a functional system, because the operating system itself isn’t my hobby - it’s what I use to pursue my hobbies.

I would still like to use NixOS, so if you have any input as to what my issues might be I’d love to hear them, but a system upgrade breaking my configuration like this in the first place sort of brings into question how much I can rely on NixOS for this system long-term. For anyone interested to look, my config files are here: GitHub - Hyfudiar/NixOSConf: My NixOS configuration · GitHub (It’s amateurish I’m sure, it was just hacked together as I was learning how to use NixOS. So I’m sure it’s in a rough/messy shape, but it has worked just fine for me til now.)

You misunderstand a bit. The driver does work, but configuring it is different, and the upstream options are horrendously misleading.

In particular, I suspect your confusion comes from the fact that wayland compositors will by default render in “offload” mode for most hard-/firmware. This means you need to explicitly use the PRIME variables to tell your computer to offload rendering applications to your dGPU (or explicitly ask the compositor to treat your dGPU as your primary GPU).


But that, too, is unrelated to your what caused your GPU to stop working. 26.05 (or even just updating 25.11) will update your NVIDIA driver to a version newer than 580. This is fairly recent, ~2 months or so.

With this new version, your GPU is no longer supported by the latest driver. You need to explicitly choose the legacy branch.

Try changing your nvidia.nix to this (your current version is based on outright lies from the wiki):

{ config, lib, ... }: {
  assertions = lib.singleton {
    assertion = config.boot.kernelPackages.kernel.isLTS;
    message = ''
      The nvidia driver can only support the LTS kernel.
      Do not modify `boot.kernelPackages`.
    '';
  };

  # Enable OpenGL
  hardware.graphics.enable = true;

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {    
    # Quadro P520
    open = false;
    branch = "legacy_580";

    powerManagement = {
      # Suspend the full GPU memory
      enable = true;

      # Turn off when not in use
      finegrained = true;
    };
  };

  hardware.nvidia.prime = {
    sync.enable = true;

    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:60:0:0";
  };
}

Once you get that working, we can take a look at making wayland work as you expect.

As an aside, since you set sync.enable, your iGPU is effectively doing nothing. Are you sure this is what you want? You can improve your battery life quite a bit by using the iGPU and choosing specific applications to run on the dGPU.

ETA: Little check that we aren’t doing silly things with boot.kernelPackages.

3 Likes

Thanks! I’ll try this today.

(your current version is based on outright lies from the wiki)

UGHHHHHH yeah not a surprise there. It’s obnoxious to have two wikis with slightly different information that are both inaccurate

Also obnoxious that evidently nixos-hardware is working off of the same incorrect information

You can improve your battery life quite a bit by using the iGPU and choosing specific applications to run on the dGPU.

It’s not too much of a concern for me, and I run plenty of things that I’m not entirely sure how it would be possible for me to choose to run them on the dGPU. E.g., audio plugins running in REAPER that are running via yabridge (something that uses WINE to run Windows audio plugins). Do I necessarily need to run many of them on the dGPU? Probably not, but I’d generally prefer to use the hardware I have access to even if it will go through my battery faster.

AFAICT from a quick read they don’t do anything special and just inherit the same PRIME constraints as their parent processes. So you’d just have to start REAPER with the same prime-offload command (or the correct environment variables) you’d have to start any other process you want to use with your dGPU.

But if you don’t mind too much, this is how you’d patch your nvidia.nix to force GNOME to run entirely on your dGPU:

{ config, lib, pkgs, ... }: {
  assertions = lib.singleton {
    assertion = config.boot.kernelPackages.kernel.isLTS;
    message = ''
      The nvidia driver can only support the LTS kernel.
      Do not modify `boot.kernelPackages`.
    '';
  };

  # Enable OpenGL
  hardware.graphics.enable = true;

  services = {
    # Load nvidia driver for Xorg and Wayland
    xserver.videoDrivers = ["nvidia"];

    # Set up the primary GPU for GNOME
    udev.packages = pkgs.writeTextDir "lib/udev/rules.d/62-gnome-gpu-priority.rules" ''
      SYMLINK=="dri/by-path/pci-0000:3c:0.0-card", TAG+="mutter-device-preferred-primary"
    '';
  };

  hardware.nvidia = {    
    # Quadro P520
    open = false;
    branch = "legacy_580";

    powerManagement = {
      # Suspend the full GPU memory
      enable = true;

      # Turn off when not in use
      finegrained = true;
    };
  };

  # These settings are entirely ignored on Wayland, but alas settings like
  # `powermanagement.finegrained` force you to set them anyway.
  #
  # This is one of those cases where the NixOS module is almost as bad as
  # the wikis.
  hardware.nvidia.prime = {
    sync.enable = true;

    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:60:0:0";
  };
}

The added udev rule should tag your NVIDIA GPU with GNOME’s primary-gpu-setting device tag, which will make it use it as the default main GPU. After this your Wayland session should work as expected (though it might be worth checking in the /dev/dri/by-path directory that I translated your GPUs PCI ID correctly).

You don’t specify if you use GNOME/Plasma/something else - the above only works on GNOME, I’m saving you the extra text required for a generic solution, but if you use something else, shout, I’ll give you the magic formulas required.

Ah, also, since I just spotted this; that issue is caused by this line: NixOSConf/configuration.nix at 8efbc61e54cd190bfe6a29ae79e20a0f223a941c · Hyfudiar/NixOSConf · GitHub

When using the NVIDIA driver, you must never use the latest Linux kernel. NVIDIA do not, and cannot, test against a kernel that wasn’t even released yet when they developed their driver. At best you get these compilation failures, at worst your computer spontaneously combusts.

Use the default, LTS kernel. So, in other words just delete that line.

Thank you very much! And yeah, I’m running Plasma, if you can provide whatever other info I’d need for that it would be appreciated.

you must never use the latest Linux kernel

That makes sense, though I would have expected that to only be the case for modern GPUs. But I can see why that isn’t the case now. That post I shared about Wayland and Nvidia even alludes to that, though it doesn’t actually mention what the issue with it is, haha. edit: LMAO i only just noticed that you were the one who made that post

Plasma uses an environment variable for this. Unlike the wlroots variable, this one accepts escaping the : delimiter, so we don’t have to muck around with creating secondary symlinks:

# nvidia.nix
{
  config,
  lib,
  ...
}:
{
  assertions = lib.singleton {
    assertion = config.boot.kernelPackages.kernel.isLTS;
    message = ''
      The nvidia driver can only support the LTS kernel.
      Do not modify `boot.kernelPackages`.
    '';
  };

  # Force Plasma to only use the NVIDIA GPU
  environment.variables.KWIN_DRM_DEVICES = lib.escape [ ":" ] "/dev/dri/by-path/pci-0000:3c:0.0-card";

  # Enable OpenGL
  hardware.graphics.enable = true;

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    # Quadro P520
    open = false;
    branch = "legacy_580";

    powerManagement = {
      # Suspend the full GPU memory
      enable = true;

      # Turn off when not in use
      finegrained = true;
    };
  };

  # These settings are entirely ignored on Wayland, but alas settings like
  # `powermanagement.finegrained` force you to set them anyway.
  #
  # This is one of those cases where the NixOS module is almost as bad as
  # the wikis.
  hardware.nvidia.prime = {
    sync.enable = true;

    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:60:0:0";
  };
}

There may be subtly nicer places to put that environment variable (e.g. polkit variables), but this is the most generic way to do it.

Yeah :wink: I seem to do most NVIDIA support on this forum in general. Not sure how I feel about providing tech support free-of-charge for the company I probably hate most on earth at the moment, but whatever. At least the wiki and LLMs suck, so all I’m doing is really just help people adopt NixOS.

4 Likes