Using older revisions of nvidia drivers

I’m having a bit of trouble updating a Thinkpad P51 to 23.05. When I move it to 23.05, X won’t start. I’ve reviewed the log messages, and I believe it’s likely due to some incompatibility between the specific graphics adapter in this P51 (a Quadro M1200) and the latest NVIDIA 530 drivers (because 22.11 works fine on the system with the 520 drivers, and 23.05 works fine on a Thinkpad P50 system with a slightly older Quadro card).

Here’s what I’ve tried in a flakes-based config to pin the NVIDIA driver (and the kernel) to 22.11’s driver and kernel:


{ config, pkgs, nixpkgs, nixpkgs-2211, ...}:

  # We'll use this twice
  pinnedKernelPackages = nixpkgs-2211.linuxPackages_latest;


  # allow nvidia drivers to be loaded 
  nixpkgs.config.allowUnfree = true;

  nixpkgs.config.packageOverrides = pkgs: {
    # swap out all of the linux packages
    linuxPackages_latest = pinnedKernelPackages;

    # make sure x11 will use the correct package as well
    nvidia_x11 = nixpkgs-2211.nvidia_x11;

  # line up your kernel packages at boot
  boot.kernelPackages = pinnedKernelPackages;

Then in my flake.nix I put:

inpuits = {
    nixpkgs-2211.url = "github:NixOS/nixpkgs/nixos-22.11";

  outputs = { self, nixpkgs, nix, nixos-hardware, home-manager, nixpkgs-2211 }:

… and imported oldnvidia.nix in a file included ih the modules list of the system I’m trying to configure.

When I try to validate this configuration, this is what happens:

/etc/nixos  23.05 *4 +1 !4 ?1  nixos-rebuild test                                                                                                                                                                      1 ✘  6s 
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: attribute 'nixpkgs-2211' missing

       at /nix/store/9c6ikvw6cmd24gw39l881sjvaq09yrkp-source/lib/modules.nix:512:28:

          511|         builtins.addErrorContext (context name)
          512|           (args.${name} or config._module.args.${name})
             |                            ^
          513|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)

Apologies if this is something dumb, but I could use some help.

For anyone else experiencing this, I have discovered that this issue is only when the system is set to “Discrete” mode for display in the BIOS. When set to “Hybrid”, X comes up.

I’m still pretty clueless about how to use an older nvidia driver revision, so please don’t consider this comment “it’s solved”, I just wanted to provide some context for people in maybe the same boat.

So, you just need to actually pass your nixpkgs-2211 to specialArgs: dotfiles/flake.nix at 9c25913a60f9982015db07df6513caed4b76646c · TLATER/dotfiles · GitHub

I really should write that blog post on how to use inputs in flakes used for NixOS systems. This question comes up so often.

On that note, though, I’m not convinced this is the best way of doing this. Using an old kernel strikes me as quite drastic. It also doesn’t look like the build process for the nvidia package has changed much recently, so this is probably a case where just overriding the source is a better call?

I’d probably try something like:

  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable.overrideAttrs(old: let
    version = "520.56.06";
    src = fetchurl {
      urls = [
      sha256 = "";

That said, the way the kernelPackages work always confuses me, so this may not work at all.

1 Like

Feel free to link to mine.


Right on, thank you (and NobbZ)! I’m getting further.

Yeah, that didn’t work (a variant on it sees the 530 driver still installed). I’ll report back when I figure it out. Thanks so much.

1 Like

It turns out that the “production” NVIDIA driver works, so “hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.production;” is all that was necessary (it installs the 525 driver).

I’d still like to know how to pin a specific driver version and not one named symbolically but I was unable to get there, and likely won’t while the above works.

1 Like

Since I had problems with the 535 driver and TLATERs solution didn’t quite work for me, I used this to pin the driver:

  hardware.nvidia.package = (config.boot.kernelPackages.nvidiaPackages.stable.overrideAttrs {
    src = pkgs.fetchurl {
      url = "";
      sha256 = "17av8nvxzn5af3x6y8vy5g6zbwg21s7sq5vpa1xc6cx8yj4mc9xm";

Unfortunately when just leaving the sha empty, it did not show me the right one so I got the right sha with:

nix-prefetch-url ""

i had issues where my laptop’s gpu (rtx 3070ti) would never be put to sleep in offload mode, spent quite a lot of time troubleshooting until i realised it may be a driver issue, @marci 's solution fixed it, only thing i changed is that there is a slightly more recent 525 driver (525.147.05).
thank you @marci, this one was quite the headscratcher.