python312Packages.vdf: avoid using pname for src.repo
[NixPkgs.git] / pkgs / os-specific / linux / nvidia-x11 / default.nix
blobdd4cd3d94a17acc6103f1afa7464724fca0810ca
1 { lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }:
3 let
4   generic = args: let
5     imported = import ./generic.nix args;
6   in callPackage imported {
7     lib32 = (pkgsi686Linux.callPackage imported {
8       libsOnly = true;
9       kernel = null;
10     }).out;
11   };
13   kernel = callPackage # a hacky way of extracting parameters from callPackage
14     ({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { };
16   selectHighestVersion = a: b: if lib.versionOlder a.version b.version
17     then b
18     else a;
20   # https://forums.developer.nvidia.com/t/linux-6-7-3-545-29-06-550-40-07-error-modpost-gpl-incompatible-module-nvidia-ko-uses-gpl-only-symbol-rcu-read-lock/280908/19
21   rcu_patch = fetchpatch {
22     url = "https://github.com/gentoo/gentoo/raw/c64caf53/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.223.02-gpl-pfn_valid.patch";
23     hash = "sha256-eZiQQp2S/asE7MfGvfe6dA/kdCvek9SYa/FFGp24dVg=";
24   };
26 rec {
27   mkDriver = generic;
29   # Official Unix Drivers - https://www.nvidia.com/en-us/drivers/unix/
30   # Branch/Maturity data - http://people.freedesktop.org/~aplattner/nvidia-versions.txt
32   # Policy: use the highest stable version as the default (on our master).
33   stable = if stdenv.hostPlatform.system == "i686-linux" then legacy_390 else latest;
35   production = generic {
36     version = "550.107.02";
37     sha256_64bit = "sha256-+XwcpN8wYCjYjHrtYx+oBhtVxXxMI02FO1ddjM5sAWg=";
38     sha256_aarch64 = "sha256-mVEeFWHOFyhl3TGx1xy5EhnIS/nRMooQ3+LdyGe69TQ=";
39     openSha256 = "sha256-Po+pASZdBaNDeu5h8sgYgP9YyFAm9ywf/8iyyAaLm+w=";
40     settingsSha256 = "sha256-WFZhQZB6zL9d5MUChl2kCKQ1q9SgD0JlP4CMXEwp2jE=";
41     persistencedSha256 = "sha256-Vz33gNYapQ4++hMqH3zBB4MyjxLxwasvLzUJsCcyY4k=";
42   };
44   latest = selectHighestVersion production (generic {
45     version = "560.35.03";
46     sha256_64bit = "sha256-8pMskvrdQ8WyNBvkU/xPc/CtcYXCa7ekP73oGuKfH+M=";
47     sha256_aarch64 = "sha256-s8ZAVKvRNXpjxRYqM3E5oss5FdqW+tv1qQC2pDjfG+s=";
48     openSha256 = "sha256-/32Zf0dKrofTmPZ3Ratw4vDM7B+OgpC4p7s+RHUjCrg=";
49     settingsSha256 = "sha256-kQsvDgnxis9ANFmwIwB7HX5MkIAcpEEAHc8IBOLdXvk=";
50     persistencedSha256 = "sha256-E2J2wYYyRu7Kc3MMZz/8ZIemcZg68rkzvqEwFAL3fFs=";
51   });
53   beta = selectHighestVersion latest (generic {
54     version = "560.31.02";
55     sha256_64bit = "sha256-0cwgejoFsefl2M6jdWZC+CKc58CqOXDjSi4saVPNKY0=";
56     sha256_aarch64 = "sha256-m7da+/Uc2+BOYj6mGON75h03hKlIWItHORc5+UvXBQc=";
57     openSha256 = "sha256-X5UzbIkILvo0QZlsTl9PisosgPj/XRmuuMH+cDohdZQ=";
58     settingsSha256 = "sha256-A3SzGAW4vR2uxT1Cv+Pn+Sbm9lLF5a/DGzlnPhxVvmE=";
59     persistencedSha256 = "sha256-BDtdpH5f9/PutG3Pv9G4ekqHafPm3xgDYdTcQumyMtg=";
60   });
62   # Vulkan developer beta driver
63   # See here for more information: https://developer.nvidia.com/vulkan-driver
64   vulkan_beta = generic rec {
65     version = "550.40.71";
66     persistencedVersion = "550.54.14";
67     settingsVersion = "550.54.14";
68     sha256_64bit = "sha256-LDh3Kz7Iop+Y2rxXANuPPkDr6WKPuZ5KV9L3+RPa2d0=";
69     openSha256 = "sha256-0HGAE0SlQmEc75E0h7Oq7qu7rVfLhQoBqQF1OuHSa2Y=";
70     settingsSha256 = "sha256-m2rNASJp0i0Ez2OuqL+JpgEF0Yd8sYVCyrOoo/ln2a4=";
71     persistencedSha256 = "sha256-XaPN8jVTjdag9frLPgBtqvO/goB5zxeGzaTU0CdL6C4=";
72     url = "https://developer.nvidia.com/downloads/vulkan-beta-${lib.concatStrings (lib.splitVersion version)}-linux";
73   };
75   # data center driver compatible with current default cudaPackages
76   dc = dc_520;
77   dc_520 = generic rec {
78     version = "520.61.05";
79     url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
80     sha256_64bit = "sha256-EPYWZwOur/6iN/otDMrNDpNXr1mzu8cIqQl8lXhQlzU==";
81     fabricmanagerSha256 = "sha256-o8Kbmkg7qczKQclaGvEyXNzEOWq9ZpQZn9syeffnEiE==";
82     useSettings = false;
83     usePersistenced = false;
84     useFabricmanager = true;
86     patches = [ rcu_patch ];
88     broken = kernel.kernelAtLeast "6.5";
89   };
91   dc_535 = generic rec {
92     version = "535.154.05";
93     url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
94     sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
95     persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";
96     fabricmanagerSha256 = "sha256-/HQfV7YA3MYVmre/sz897PF6tc6MaMiS/h7Q10m2p/o=";
97     useSettings = false;
98     usePersistenced = true;
99     useFabricmanager = true;
101     patches = [ rcu_patch ];
102   };
104   # Update note:
105   # If you add a legacy driver here, also update `top-level/linux-kernels.nix`,
106   # adding to the `nvidia_x11_legacy*` entries.
108   # Last one without the bug reported here:
109   # https://bbs.archlinux.org/viewtopic.php?pid=2155426#p2155426
110   legacy_535 = generic {
111     version = "535.154.05";
112     sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
113     sha256_aarch64 = "sha256-G0/GiObf/BZMkzzET8HQjdIcvCSqB1uhsinro2HLK9k=";
114     openSha256 = "sha256-wvRdHguGLxS0mR06P5Qi++pDJBCF8pJ8hr4T8O6TJIo=";
115     settingsSha256 = "sha256-9wqoDEWY4I7weWW05F4igj1Gj9wjHsREFMztfEmqm10=";
116     persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";
118     patches = [ rcu_patch ];
119   };
121   # Last one supporting Kepler architecture
122   legacy_470 = generic {
123     version = "470.256.02";
124     sha256_64bit = "sha256-1kUYYt62lbsER/O3zWJo9z6BFowQ4sEFl/8/oBNJsd4=";
125     sha256_aarch64 = "sha256-e+QvE+S3Fv3JRqC9ZyxTSiCu8gJdZXSz10gF/EN6DY0=";
126     settingsSha256 = "sha256-kftQ4JB0iSlE8r/Ze/+UMnwLzn0nfQtqYXBj+t6Aguk=";
127     persistencedSha256 = "sha256-iYoSib9VEdwjOPBP1+Hx5wCIMhW8q8cCHu9PULWfnyQ=";
128   };
130   # Last one supporting x86
131   legacy_390 = let
132     # Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
133     aurPatches = fetchgit {
134       url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
135       rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3";
136       hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E=";
137     };
138     patchset = [
139       "kernel-4.16+-memory-encryption.patch"
140       "kernel-6.2.patch"
141       "kernel-6.3.patch"
142       "kernel-6.4.patch"
143       "kernel-6.5.patch"
144       "kernel-6.6.patch"
145       "kernel-6.8.patch"
146       "gcc-14.patch"
147       "kernel-6.10.patch"
148     ];
149   in generic {
150     version = "390.157";
151     sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k=";
152     sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo=";
153     settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw=";
154     persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns=";
156     patches = map (patch: "${aurPatches}/${patch}") patchset;
157     broken = kernel.kernelAtLeast "6.11 ";
159     # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
160     # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
161     # and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
162     postInstall = ''
163       mv $out/lib/tls/* $out/lib
164       rmdir $out/lib/tls
165     '';
166   };
168   legacy_340 = let
169     # Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms
170     aurPatches = fetchFromGitHub {
171       owner = "archlinux-jerry";
172       repo = "nvidia-340xx";
173       rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90";
174       hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo=";
175     };
176     patchset = [
177       "0001-kernel-5.7.patch"
178       "0002-kernel-5.8.patch"
179       "0003-kernel-5.9.patch"
180       "0004-kernel-5.10.patch"
181       "0005-kernel-5.11.patch"
182       "0006-kernel-5.14.patch"
183       "0007-kernel-5.15.patch"
184       "0008-kernel-5.16.patch"
185       "0009-kernel-5.17.patch"
186       "0010-kernel-5.18.patch"
187       "0011-kernel-6.0.patch"
188       "0012-kernel-6.2.patch"
189       "0013-kernel-6.3.patch"
190       "0014-kernel-6.5.patch"
191       "0015-kernel-6.6.patch"
192     ];
193   in generic {
194     version = "340.108";
195     sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0";
196     sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6";
197     settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34";
198     persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn";
199     useGLVND = false;
201     broken = kernel.kernelAtLeast "6.7";
202     patches = map (patch: "${aurPatches}/${patch}") patchset;
204     # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
205     # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
206     # and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
207     postInstall = ''
208       mv $out/lib/tls/* $out/lib
209       rmdir $out/lib/tls
210     '';
211   };