Unable to build nix due to nvidia drivers due or kernel 6.10(?)

I ran sudo nixos-rebuild switch --upgrade, and I think my nvidia drivers or kernel 6.10 have conflicts building in my system:

/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h: In function 'nv_ioremap_cache':
/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h:531:33: warning: suggest braces around empty body in an 'if' statement [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wempty-body-Wempty-body8;;]
  531 |         NV_MEMDBG_ADD(ptr, size);
      |                                 ^
/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h: In function 'nv_ioremap_wc':
/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h:548:33: warning: suggest braces around empty body in an 'if' statement [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wempty-body-Wempty-body8;;]
  548 |         NV_MEMDBG_ADD(ptr, size);
      |                                 ^
/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h: In function 'nv_vmap':
/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h:674:51: warning: suggest braces around empty body in an 'if' statement [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wempty-body-Wempty-body8;;]
  674 |         NV_MEMDBG_ADD(ptr, page_count * PAGE_SIZE);
      |                                                   ^
make[3]: *** [/nix/store/69yq78xvmflsfc7b3s45s49k1mlybbh0-linux-6.10-dev/lib/modules/6.10.0/source/Makefile:1934: /build/NVIDIA-Linux-x86_64-550.78/kernel] Error 2
make[2]: *** [/nix/store/69yq78xvmflsfc7b3s45s49k1mlybbh0-linux-6.10-dev/lib/modules/6.10.0/source/Makefile:240: __sub-make] Error 2
make[2]: Leaving directory '/nix/store/69yq78xvmflsfc7b3s45s49k1mlybbh0-linux-6.10-dev/lib/modules/6.10.0/build'
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/nix/store/69yq78xvmflsfc7b3s45s49k1mlybbh0-linux-6.10-dev/lib/modules/6.10.0/source'
make: *** [Makefile:85: modules] Error 2
error: builder for '/nix/store/95mqmrr9zksqzncqn7bj2zr9lhpq1jqn-nvidia-x11-550.78-6.10.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/gc5ibgzpxhl9m7cyig8ig0v6n4994q9c-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2hq0javg06sc65grpaw3hm64likfbvd7-linux-6.10-modules.drv' failed to build
error: 1 dependencies of derivation '/nix/store/bqmkgyv0d0brjzcmsi9ii7n1zr1nqy36-ollama-0.1.38.drv' failed to build
error: 1 dependencies of derivation '/nix/store/63pc5a65h9hxsglldv4ccywaq1xijy6f-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/p9cq7kkiwp4mgcs7p0cx9b5gywbyd8c2-nixos-system-nixos-DJ_Pilot1_1tb-nvidia-gpu-24.05.2933.c716603a63ac.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kh0q248w1532cd6k242bn9zvf2kawn1q-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/m962w4y1xn3hhs1w5rid7ds3jpb4j18b-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xyc03mv6hl1rd47kln1whrdl9i258vvy-unit-ollama.service.drv' failed to build
error: 1 dependencies of derivation '/nix/store/yr85a5fdz8jdgvwlqp68asg0v56kz70r-nixos-system-nixos-DJ_Pilot1_1tb-24.05.2933.c716603a63ac.drv' failed to build

1 Like

I don’t see anything about conflicts here. Also your error mesage is further up, these logs are insufficient to troubleshoot.

I’ve got the same error. Here is the part of the log with the error:

/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h:599:37: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  599 |             NV_MEMDBG_ADD(ptr, size); \
      |                                     ^
/build/NVIDIA-Linux-x86_64-550.78/kernel/nvidia/os-interface.c:594:13: note: in expansion of macro 'NV_KMALLOC_NO_OOM'
  594 |             NV_KMALLOC_NO_OOM(*address, alloc_size);
      |             ^~~~~~~~~~~~~~~~~
/build/NVIDIA-Linux-x86_64-550.78/kernel/nvidia/os-mlock.c: In function 'nv_follow_pfn':
/build/NVIDIA-Linux-x86_64-550.78/kernel/nvidia/os-mlock.c:42:12: error: implicit declaration of function 'follow_pfn'; did you mean 'follow_pte'? [-Werror=implicit-function-declaration]
   42 |     return follow_pfn(vma, address, pfn);
      |            ^~~~~~~~~~
      |            follow_pte
/build/NVIDIA-Linux-x86_64-550.78/kernel/nvidia/os-interface.c: In function 'os_queue_work_item':
/build/NVIDIA-Linux-x86_64-550.78/kernel/common/inc/nv-linux.h:584:37: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  584 |             NV_MEMDBG_ADD(ptr, size); \
      |                                     ^
/build/NVIDIA-Linux-x86_64-550.78/kernel/nvidia/os-interface.c:1135:5: note: in expansion of macro 'NV_KMALLOC_ATOMIC'
 1135 |     NV_KMALLOC_ATOMIC(oqd, sizeof(os_queue_data_t));
      |     ^~~~~~~~~~~~~~~~~

And here is the full build log: notebin.de | Pastebin

A similar issue Builder for nvidia-x11-550.78-6.10.drv failed with exit code 2 has been solved by switching the kernel to 6.9, so I guess your initial suspicion is right.

You could also do the same or try changing the nvidia version and see if it still conflicts.

1 Like

It’s pretty common for the nvidia kernel module to not be compatible with a new kernel.

NixOS pulls kernels immediately when they become unsupported, too, so you usually won’t be able to downgrade to a recent-but-not-too-recent kernel without a fair bit of hassle.

Hence, when using nvidia, it’s usually best not to use linuxPackages_latest. It’s the issue with third party kernel modules, none of this would be a problem if nvidia didn’t demand their special cookie.

Usually a week or two in someone posts a patch on a weird forum, but by then a driver patch is close enough that NixOS just updates the nvidia package, and then eventually backports it to stable, and the issue disappears.

In this case you might be able to work around it by patching out -Werror or such, though, given that the error looks a lot like a warning.

3 Likes

You’re right, and this isn’t the first time that this happened to me. The last time it happened, it was also because of linuxPackages_latest, and switching back to the previous kernel fixed it.

What do folks normally have in boot.kernelPackages = pkgs.linuxPackages_X_X? Or do you prefer not to configure the kernel?

I personally use boot.kernelPackages = pkgs.linuxPackages_xanmod_latest; because of its gaming patches. The nice thing about it is that I get a fairly recent and stable kernel on each update (currently 6.9.9) without having to manually pin the version.

2 Likes

It also lags behind a little, which is often enough for nvidia to catch up.

1 Like

That’s a great point. Never thought of it that way.

I’m between xanmod and zen. How did you make your decision between the two? Also, is there a way to read the differences from those two kernels?

The most I was able to get from xanmod was from their website: https://xanmod.org/

I was running zen for a while, but I had some issues with it so I switched to xanmod and didn’t have any problems ever since. Zen might be better now, though, so you should try them both and see what works best for you.

For zen there is the Detailed Feature List. For xanmod, there is the Main Features list on their website. Aside from this, you could probably find some comparisons or benchmarks online.

At the end of the day, you should try for yourself and see if the difference is noticeable.

3 Likes

command worked, thanks, will test and report back in a few days

1 Like

I am facing the same issue, as I need both recent AMD drivers from a kernel newer than 6.6 LTS and Nvidia to work.

Any idea how to solve this ?

Well, I’m met with a new crossroads as 6.9 is now at the “end of life”:


[nprevail@nixos-joyy-black256GB:~]$ sudo nixos-rebuild switch --upgrade
[sudo] password for nprevail: 
unpacking channels...
building Nix...
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: linux 6.9 was removed because it reached its end of life upstream

Any thoughts on what nvidia users can do if they’re unable to use the latest kernel?

Pick a longterm version from https://www.kernel.org/.

Easier said than done: I use NixOS on a fairly recent laptop that needs at least 6.7. What should I do now? Should I try the Nvidia Open driver or will I run into the same problem with it?

1 Like

For me, I have no issues with xanmod (6.10.4) and Nvidia (555.58.02) both proprietary and open.

As I remember, the problem was that the kernel was too new for the drivers, but seeing that 6.10 has been out for a while, I don’t think it’s a problem anymore.

1 Like

I know what you mean, I have some hardware that requires a minimum kernel version, but nvidia (depending on how quick they are on updates) effectively sets a maximum kernel version. If there’s no supported kernel version between those two version constraints, you’re SOL.

(That’s one reason I personally don’t touch nvidia, zfs, etc. if I can help it.)

With that being said, you might as well try 6.10 to confirm if that maximum constraint really exists. This post is a month old and fixes may easily have come through since then.

Stable still uses the 550.78 driver, so maybe you need to update that:

hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
  version = "555.58.02";
  sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
  sha256_aarch64 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
  openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
  settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
  persistencedSha256 = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
};

Nvidia anyway causes enough issues that I recommend overriding the NixOS package version to just about everyone - just make sure to stay up-to-date manually. Gamingonlinux’ nvidia category is pretty nice to point an RSS feed reader at to keep track of new drivers if you do this.

Maybe we should start an nvidia flake with accompanying docs to help work around all this stuff.

8 Likes

Perfect, thank you that worked! Where did you get all the hashes from? Just so I know where I can get them if a new version comes out.

Make them empty strings and nix tells you what they actually are :stuck_out_tongue:

2 Likes