Nvidia drivers update?


I configured my dGPU by the Nvidia - NixOS Wiki guide, so everything I set up was through my configuration.nix file.

I run $ nvidia-smi, and see that the drivers currently ran on my PC are older than the newest version available according to the Nvidia website. What is the mechanism my drivers are updated by? Does it happen automatically (with me just needing to nixos-rebuild)? Can I update them ahead of the automatic update?

You can see what the current versions are here (that’s on nixos-unstable, change branch according to what you’re using). When a PR is merged updating the versions, you would then update your channel or your flake accordingly, and when you rebuild you’d get the new version of that driver.


The current version of the nvidia driver as packaged by NixOS can be seen using the package search, here for stable and here for unstable. Click the little channel buttons to switch between them, alternatively. The versions are currently 535.86.05-5.15.133 and 535.113.01-5.15.133 respectively.

They are downloaded, built and installed with nix, using the package definition from nixpkgs to figure out which version to install. In short, you’re not downloading something directly from nvidia, but a NixOS package that is set up to actually work on NixOS.

I don’t recommend trying to install nvidia’s package. If you use a Linux distro, use their packages whenever possible. This is doubly true for NixOS.

Yes (no, you need to nix-channel --update and sudo nix-channel --update beforehand).

Well, yeah, but which versions you can update to depends on how much effort you want to put in. NixOS offers stable (currently 23.05, soon 23.11) and unstable, the stable version will usually lag behind in package updates.

This is especially true for the nvidia drivers, because they don’t do stable version increments, so any update is a breaking change and therefore rare on NixOS stable (sometimes happens when nvidia doesn’t work with the kernel anymore for one reason or another).

Note that while unstable is much more recent, it is not necessarily be the most recent nvidia driver. This is because the nixpkgs maintainers will check that the driver actually works before updating it. In general I’d recommend taking their decision, but in theory you can even use versions beyond that with overrides.

I’m assuming you’re on stable currently. Ultimately if you want to update to the driver offered by NixOS unstable you have two options:

  1. Switch your whole system to unstable
  2. Grab just the kernel from unstable with its associated nvidia package

The former will mean that you’re potentially exposed to breaking changes everywhere. It’s more like running Arch Linux. The latter is not usually a good idea on other release distros like Debian, but quite feasible on NixOS.

Since we’re talking about the Linux kernel, which goes to great lengths to never break userspace, I think it’s quite ok to do the latter if you want more recent nvidia drivers. For this, you need to get a reference to the unstable channel on your system, and then do something like:

# configuration.nix, or a file `imports`-ed from it
  nixpkgs-unstable = import <nixpkgs-unstable> { };
in {
  boot.kernelPackages = nixpkgs-unstable.linuxPackages;

Since third party kernel modules like the nvidia driver and zfs are tied to the specific kernel they are built for, this will also grab the nvidia driver from unstable, without forcing any rebuilds on you. This also takes the LTS kernel release, which IME breaks the nvidia drivers much less frequently, so I would recommend it.

In theory you could also use the nvidia package from unstable with the stable kernel, but that gets more messy (not 100% sure this is even correct):

{config, ... }: let
  nixpkgs-unstable = import <nixpkgs-unstable> { };
in {
  hardware.nvidia.package = (nixpkgs-unstable.linuxPackagesFor config.boot.kernelPackages.kernel).nvidiaPackages.stable;

Either of these approaches should give you nearly the most recent nvidia driver (trying to update beyond that is usually just not worth the effort, just wait a week or two for the package maintainers to do the work for you).


here for stable

I only followed the Nix Wiki before, and it is outdated, so the option from your link

environment.systemPackages = [

is new to me. The Wiki instructs to use hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable, which I did. $ nvidia-smi shows my driver version being 530.41.03 which is (I think) much older than 535.86.05-5.15.133. Should I remove the option from the Wiki and apply the option you linked? If so, do I have to change anything else in my setup done by the Wiki?

you need to nix-channel --update and sudo nix-channel --update beforehand

To clarify: does this command actually do different things when used with & without privileges?

Thank you again for taking the time to help. The answer is very detailed, and expands my understanding of this interesting system. I’ll save some things to my personal notes.

Oh wow, that could not be more misleading. No, don’t do that. https://search.nixos.org shouldn’t be telling people to do this with packages that need to be managed via an option, but it just lists that for every package in the repository. Don’t know how to fix it, but this needs to be reported upstream.

Edit: Known bug: Installation suggestion of service packages is completely wrong · Issue #506 · NixOS/nixos-search · GitHub

Yes, which is why I’m always very explicit about stating it with both sudo and without.

You see, all users on a NixOS system have their own set of channels. Each user can independently use nix to install whatever software they want, from wherever they want. When you use nix-channel, you modify the set of channels for the user executing it.

If you never run nix-channel with sudo, you will never change the root users’ channels - and these are used for building your system, so that means your system will never be updated.

And that’s exactly why I pointed this out, I suspect your case is just this.

Nix flakes avoid this problem, sadly that’s likely still years off.

1 Like