Overriding nvidia-persistenced for NixOS

As an overlay:

nvidia = _: super: {
  linuxPackages_5_8 = super.linuxPackages_5_8.extend (_: superLinux: {
    nvidia_x11 = superLinux.nvidia_x11 // {
      persistenced = superLinux.nvidia_x11.passthru.persistenced.overrideAttrs
        (o: {
          nativeBuildInputs = [ super.m4 super.pkg-config ];
          buildInputs = [ super.libtirpc ];


  • linuxPackages must be extended rather than overridden
  • nvidia_x11 is both an attrset and a derivation, but I’m interested in overriding persistenced which is just attached to the derivation as an attribute. Consequently, // is used rather than .overrideAttrs.
  • passthru is required to override the “real” persistenced. overrideAttrs should be greatly preferred over override or overrideDerivation; both of which don’t behave like you would intuitively expect.
  • Finally, the override can take place as normal.

A complete integration example might look something like this:

  overlays = [ nvidia ]; # where "nvidia" is the function defined above
  pkgs = import <nixpkgs> { inherit overlays; };
in {
  # rest of config goes here

Although it’s important to note that this example isn’t necessarily “production ready”. If you’re going to make deep and custom changes like this, it’s a very good idea to start pinning your nixpkgs explicitly.