kotatsuyaki’s site

Downgrade Nvidia proprietary drivers on NixOS

Published on

Set the hardware.nvidia.package option to another derivation.

Nixpkgs comes with some predefined versions, available at linuxPackages.nvidiaPackages.<version> where <version> can be stable, latest, legacy_470 etc.

For other versions that are not predefined in nixpkgs, use the mkDriver function (which refers to pkgs/os-specific/linux/nvidia-x11/generic.nix) to create a derivation from the version number and hashes.

{ config, ... }: {
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
    version = "535.154.05";
    sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
    sha256_aarch64 = "sha256-G0/GiObf/BZMkzzET8HQjdIcvCSqB1uhsinro2HLK9k=";
    openSha256 = "sha256-wvRdHguGLxS0mR06P5Qi++pDJBCF8pJ8hr4T8O6TJIo=";
    settingsSha256 = "sha256-9wqoDEWY4I7weWW05F4igj1Gj9wjHsREFMztfEmqm10=";
    persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";
  };
}

The mkDriver function was introduced in PR 240075, which made it easy to copy from older versions for overriding.


My use case was to workaround a kernel panic bug present in the 550.x series of Nvidia drivers. As all I need is to rollback to a prior version, I went back to an earlier version of pkgs/os-specific/linux/nvidia-x11/default.nix and just copied the version and hashes before the upgrade to 550.

Hopefully the bug does not come back to haunt me after my two days of troubleshooting.