@@ -42,6 +42,25 @@ let
4242 }
4343 else throw "nvidia-x11 does not support platform ${stdenv.system}";
4444
45+ prePatch = let
46+ debPatches = fetchurl {
47+ url = "mirror://debian/pool/non-free/n/nvidia-graphics-drivers-legacy-304xx/"
48+ + "nvidia-graphics-drivers-legacy-304xx_304.135-2.debian.tar.xz";
49+ sha256 = "0mhji0ssn7075q5a650idigs48kzf11pzj2ca2n07rwxg3vj6pdr";
50+ };
51+ prefix = "debian/module/debian/patches";
52+ applyPatches = pnames: if pnames == [] then null else
53+ ''
54+ tar xf '${debPatches}'
55+ sed 's|^\([+-]\{3\} [ab]\)/|\1/kernel/|' -i ${prefix}/*.patch
56+ patches="$patches ${concatMapStringsSep " " (pname: "${prefix}/${pname}.patch") pnames}"
57+ '';
58+ in
59+ # TODO: perhaps other branches also need patching?
60+ if (versionOlder version "340") then applyPatches
61+ [ "fix-typos" "drm-driver-legacy" "deprecated-cpu-events" "disable-mtrr" ]
62+ else null;
63+
4564 # patch to get the nvidia and nvidiaBeta driver to compile on kernel 4.10
4665 patches = if libsOnly
4766 then null