Patch linux driver without using a custom checkout of nixpkgs

I’m trying to get the latest linux kernel compiling and failing due to an issue in Nvidia DKMS.

There are a few other related issues covering this same problem.

I’m trying to avoid having to checkout and modify nixpkgs, I just want to use the .nix configs to apply this patch.

No matter what I do, I keep getting the same compilation error, ie the patches aren’t applying.

I’ve tried:

  nixpkgs = {
    overlays = [
      (self: super: {
        linuxPackages_latest = super.linuxPackages_latest.extend (self: super: {
          nvidia_x11 = super.nvidia_x11.overrideAttrs (attrs: {
            patches = [
              (pkgs.fetchpatch {
                url = "https://raw.githubusercontent.com/Frogging-Family/nvidia-all/master/patches/kernel-5.14.patch";
                sha256 = "042zyspddka1acmli9l4h4cbzpfgq8a9lcdwjgwjr0npdgqk3j3f";
                stripLen = 2;
                extraPrefix = "kernel/";
              })
            ];
          });
        });
      })
    ];
  };
boot.kernelPatches = [{
  name = "nvidia-fix";
  patch = (pkgs.fetchpatch {
    url = "https://raw.githubusercontent.com/Frogging-Family/nvidia-all/master/patches/kernel-5.14.patch";
    sha256 = "042zyspddka1acmli9l4h4cbzpfgq8a9lcdwjgwjr0npdgqk3j3f";
    stripLen = 2;
    extraPrefix = "kernel/";
  });
}];

let
  linuxPackages_patched = pkgs.linuxPackages_latest.extend (self: super: {
    nvidia_x11 = super.nvidia_x11.overrideAttrs (oA: {
      patches = [
        (pkgs.fetchpatch {
          url = "https://raw.githubusercontent.com/Frogging-Family/nvidia-all/master/patches/kernel-5.14.patch";
          sha256 = "042zyspddka1acmli9l4h4cbzpfgq8a9lcdwjgwjr0npdgqk3j3f";
          stripLen = 2;
          extraPrefix = "kernel/";
        })
      ] ++ oA.patches;
    });
  });
in {
  boot.kernelPackages = pkgs.linuxPackages_patched;
}

I’m out of ideas, any suggestions?

2 Likes

Did you find a solution?
I’m trying to do the same

No, unfortunately not.
Do post a response if you figure it out.