tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/nvidia: run nixfmt on nvidia related files
Edward Tjörnhammar
1 year ago
51fabd13
ba556d1a
+478
-344
5 changed files
expand all
collapse all
unified
split
nixos
modules
hardware
video
nvidia.nix
pkgs
os-specific
linux
nvidia-x11
default.nix
generic.nix
open.nix
settings.nix
+34
-24
nixos/modules/hardware/video/nvidia.nix
···
92
information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux
93
'';
94
95
-
modesetting.enable = lib.mkEnableOption ''
96
-
kernel modesetting when using the NVIDIA proprietary driver.
0
97
98
-
Enabling this fixes screen tearing when using Optimus via PRIME (see
99
-
{option}`hardware.nvidia.prime.sync.enable`. This is not enabled
100
-
by default because it is not officially supported by NVIDIA and would not
101
-
work with SLI.
102
103
-
Enabling this and using version 545 or newer of the proprietary NVIDIA
104
-
driver causes it to provide its own framebuffer device, which can cause
105
-
Wayland compositors to work when they otherwise wouldn't.
106
-
'' // {
107
-
default = lib.versionAtLeast cfg.package.version "535";
108
-
defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\"";
109
-
};
0
110
111
prime.nvidiaBusId = lib.mkOption {
112
type = busIDType;
···
266
'';
267
};
268
269
-
gsp.enable = lib.mkEnableOption ''
270
-
the GPU System Processor (GSP) on the video card
271
-
'' // {
272
-
default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555";
273
-
defaultText = lib.literalExpression ''
274
-
config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555"
275
-
'';
276
-
};
0
0
277
278
videoAcceleration =
279
(lib.mkEnableOption ''
···
323
softdep nvidia post: nvidia-uvm
324
'';
325
};
326
-
systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ];
0
0
327
services.udev.extraRules = ''
328
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
329
KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'"
···
622
# If requested enable modesetting via kernel parameters.
623
kernelParams =
624
lib.optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1"
625
-
++ lib.optional ((offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545") "nvidia-drm.fbdev=1"
0
0
626
++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
627
++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1"
628
++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off";
···
683
TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
684
DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
685
};
686
-
nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (fabricManagerConfDefaults // cfg.datacenter.settings);
0
0
687
in
688
"${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}";
689
LimitCORE = "infinity";
···
92
information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux
93
'';
94
95
+
modesetting.enable =
96
+
lib.mkEnableOption ''
97
+
kernel modesetting when using the NVIDIA proprietary driver.
98
99
+
Enabling this fixes screen tearing when using Optimus via PRIME (see
100
+
{option}`hardware.nvidia.prime.sync.enable`. This is not enabled
101
+
by default because it is not officially supported by NVIDIA and would not
102
+
work with SLI.
103
104
+
Enabling this and using version 545 or newer of the proprietary NVIDIA
105
+
driver causes it to provide its own framebuffer device, which can cause
106
+
Wayland compositors to work when they otherwise wouldn't.
107
+
''
108
+
// {
109
+
default = lib.versionAtLeast cfg.package.version "535";
110
+
defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\"";
111
+
};
112
113
prime.nvidiaBusId = lib.mkOption {
114
type = busIDType;
···
268
'';
269
};
270
271
+
gsp.enable =
272
+
lib.mkEnableOption ''
273
+
the GPU System Processor (GSP) on the video card
274
+
''
275
+
// {
276
+
default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555";
277
+
defaultText = lib.literalExpression ''
278
+
config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555"
279
+
'';
280
+
};
281
282
videoAcceleration =
283
(lib.mkEnableOption ''
···
327
softdep nvidia post: nvidia-uvm
328
'';
329
};
330
+
systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [
331
+
"L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin"
332
+
];
333
services.udev.extraRules = ''
334
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
335
KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'"
···
628
# If requested enable modesetting via kernel parameters.
629
kernelParams =
630
lib.optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1"
631
+
++ lib.optional (
632
+
(offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545"
633
+
) "nvidia-drm.fbdev=1"
634
++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
635
++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1"
636
++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off";
···
691
TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
692
DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
693
};
694
+
nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (
695
+
fabricManagerConfDefaults // cfg.datacenter.settings
696
+
);
697
in
698
"${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}";
699
LimitCORE = "infinity";
+112
-91
pkgs/os-specific/linux/nvidia-x11/default.nix
···
1
-
{ lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }:
0
0
0
0
0
0
0
0
2
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
-
};
0
0
0
0
12
13
-
kernel = callPackage # a hacky way of extracting parameters from callPackage
14
-
({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { };
0
0
0
0
0
0
0
15
16
-
selectHighestVersion = a: b: if lib.versionOlder a.version b.version
17
-
then b
18
-
else a;
19
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 {
···
25
26
# Fixes drm device not working with linux 6.12
27
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/712
28
-
drm_fop_flags_linux_612_patch = fetchpatch {
29
url = "https://github.com/Binary-Eater/open-gpu-kernel-modules/commit/8ac26d3c66ea88b0f80504bdd1e907658b41609d.patch";
30
hash = "sha256-+SfIu3uYNQCf/KXhv4PWvruTVKQSh4bgU1moePhe57U=";
31
};
···
136
};
137
138
# Last one supporting x86
139
-
legacy_390 = let
140
-
# Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
141
-
aurPatches = fetchgit {
142
-
url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
143
-
rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3";
144
-
hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E=";
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
145
};
146
-
patchset = [
147
-
"kernel-4.16+-memory-encryption.patch"
148
-
"kernel-6.2.patch"
149
-
"kernel-6.3.patch"
150
-
"kernel-6.4.patch"
151
-
"kernel-6.5.patch"
152
-
"kernel-6.6.patch"
153
-
"kernel-6.8.patch"
154
-
"gcc-14.patch"
155
-
"kernel-6.10.patch"
156
-
];
157
-
in generic {
158
-
version = "390.157";
159
-
sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k=";
160
-
sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo=";
161
-
settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw=";
162
-
persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns=";
163
164
-
patches = map (patch: "${aurPatches}/${patch}") patchset;
165
-
broken = kernel.kernelAtLeast "6.11 ";
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
166
167
-
# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
168
-
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
169
-
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
170
-
postInstall = ''
171
-
mv $out/lib/tls/* $out/lib
172
-
rmdir $out/lib/tls
173
-
'';
174
-
};
175
176
-
legacy_340 = let
177
-
# Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms
178
-
aurPatches = fetchFromGitHub {
179
-
owner = "archlinux-jerry";
180
-
repo = "nvidia-340xx";
181
-
rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90";
182
-
hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo=";
183
};
184
-
patchset = [
185
-
"0001-kernel-5.7.patch"
186
-
"0002-kernel-5.8.patch"
187
-
"0003-kernel-5.9.patch"
188
-
"0004-kernel-5.10.patch"
189
-
"0005-kernel-5.11.patch"
190
-
"0006-kernel-5.14.patch"
191
-
"0007-kernel-5.15.patch"
192
-
"0008-kernel-5.16.patch"
193
-
"0009-kernel-5.17.patch"
194
-
"0010-kernel-5.18.patch"
195
-
"0011-kernel-6.0.patch"
196
-
"0012-kernel-6.2.patch"
197
-
"0013-kernel-6.3.patch"
198
-
"0014-kernel-6.5.patch"
199
-
"0015-kernel-6.6.patch"
200
-
];
201
-
in generic {
202
-
version = "340.108";
203
-
sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0";
204
-
sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6";
205
-
settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34";
206
-
persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn";
207
-
useGLVND = false;
208
-
209
-
broken = kernel.kernelAtLeast "6.7";
210
-
patches = map (patch: "${aurPatches}/${patch}") patchset;
211
-
212
-
# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
213
-
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
214
-
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
215
-
postInstall = ''
216
-
mv $out/lib/tls/* $out/lib
217
-
rmdir $out/lib/tls
218
-
'';
219
-
};
220
}
···
1
+
{
2
+
lib,
3
+
callPackage,
4
+
fetchFromGitHub,
5
+
fetchgit,
6
+
fetchpatch,
7
+
stdenv,
8
+
pkgsi686Linux,
9
+
}:
10
11
let
12
+
generic =
13
+
args:
14
+
let
15
+
imported = import ./generic.nix args;
16
+
in
17
+
callPackage imported {
18
+
lib32 =
19
+
(pkgsi686Linux.callPackage imported {
20
+
libsOnly = true;
21
+
kernel = null;
22
+
}).out;
23
+
};
24
25
+
kernel =
26
+
# a hacky way of extracting parameters from callPackage
27
+
callPackage (
28
+
{
29
+
kernel,
30
+
libsOnly ? false,
31
+
}:
32
+
if libsOnly then { } else kernel
33
+
) { };
34
35
+
selectHighestVersion = a: b: if lib.versionOlder a.version b.version then b else a;
0
0
36
37
# 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
38
rcu_patch = fetchpatch {
···
42
43
# Fixes drm device not working with linux 6.12
44
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/712
45
+
drm_fop_flags_linux_612_patch = fetchpatch {
46
url = "https://github.com/Binary-Eater/open-gpu-kernel-modules/commit/8ac26d3c66ea88b0f80504bdd1e907658b41609d.patch";
47
hash = "sha256-+SfIu3uYNQCf/KXhv4PWvruTVKQSh4bgU1moePhe57U=";
48
};
···
153
};
154
155
# Last one supporting x86
156
+
legacy_390 =
157
+
let
158
+
# Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
159
+
aurPatches = fetchgit {
160
+
url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
161
+
rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3";
162
+
hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E=";
163
+
};
164
+
patchset = [
165
+
"kernel-4.16+-memory-encryption.patch"
166
+
"kernel-6.2.patch"
167
+
"kernel-6.3.patch"
168
+
"kernel-6.4.patch"
169
+
"kernel-6.5.patch"
170
+
"kernel-6.6.patch"
171
+
"kernel-6.8.patch"
172
+
"gcc-14.patch"
173
+
"kernel-6.10.patch"
174
+
];
175
+
in
176
+
generic {
177
+
version = "390.157";
178
+
sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k=";
179
+
sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo=";
180
+
settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw=";
181
+
persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns=";
182
+
183
+
patches = map (patch: "${aurPatches}/${patch}") patchset;
184
+
broken = kernel.kernelAtLeast "6.11 ";
185
+
186
+
# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
187
+
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
188
+
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
189
+
postInstall = ''
190
+
mv $out/lib/tls/* $out/lib
191
+
rmdir $out/lib/tls
192
+
'';
193
};
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
194
195
+
legacy_340 =
196
+
let
197
+
# Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms
198
+
aurPatches = fetchFromGitHub {
199
+
owner = "archlinux-jerry";
200
+
repo = "nvidia-340xx";
201
+
rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90";
202
+
hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo=";
203
+
};
204
+
patchset = [
205
+
"0001-kernel-5.7.patch"
206
+
"0002-kernel-5.8.patch"
207
+
"0003-kernel-5.9.patch"
208
+
"0004-kernel-5.10.patch"
209
+
"0005-kernel-5.11.patch"
210
+
"0006-kernel-5.14.patch"
211
+
"0007-kernel-5.15.patch"
212
+
"0008-kernel-5.16.patch"
213
+
"0009-kernel-5.17.patch"
214
+
"0010-kernel-5.18.patch"
215
+
"0011-kernel-6.0.patch"
216
+
"0012-kernel-6.2.patch"
217
+
"0013-kernel-6.3.patch"
218
+
"0014-kernel-6.5.patch"
219
+
"0015-kernel-6.6.patch"
220
+
];
221
+
in
222
+
generic {
223
+
version = "340.108";
224
+
sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0";
225
+
sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6";
226
+
settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34";
227
+
persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn";
228
+
useGLVND = false;
229
230
+
broken = kernel.kernelAtLeast "6.7";
231
+
patches = map (patch: "${aurPatches}/${patch}") patchset;
0
0
0
0
0
0
232
233
+
# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
234
+
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
235
+
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
236
+
postInstall = ''
237
+
mv $out/lib/tls/* $out/lib
238
+
rmdir $out/lib/tls
239
+
'';
240
};
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
241
}
+188
-131
pkgs/os-specific/linux/nvidia-x11/generic.nix
···
1
-
{ version
2
-
, url ? null
3
-
, sha256_32bit ? null
4
-
, sha256_64bit
5
-
, sha256_aarch64 ? null
6
-
, openSha256 ? null
7
-
, settingsSha256 ? null
8
-
, settingsVersion ? version
9
-
, persistencedSha256 ? null
10
-
, persistencedVersion ? version
11
-
, fabricmanagerSha256 ? null
12
-
, fabricmanagerVersion ? version
13
-
, useGLVND ? true
14
-
, useProfiles ? true
15
-
, preferGtk2 ? false
16
-
, settings32Bit ? false
17
-
, useSettings ? true
18
-
, usePersistenced ? true
19
-
, useFabricmanager ? false
20
-
, ibtSupport ? false
0
21
22
-
, prePatch ? null
23
-
, postPatch ? null
24
-
, patchFlags ? null
25
-
, patches ? [ ]
26
-
, patchesOpen ? [ ]
27
-
, preInstall ? null
28
-
, postInstall ? null
29
-
, broken ? false
30
-
, brokenOpen ? broken
31
}@args:
32
33
-
{ lib
34
-
, stdenv
35
-
, runCommandLocal
36
-
, patchutils
37
-
, callPackage
38
-
, pkgs
39
-
, pkgsi686Linux
40
-
, fetchurl
41
-
, fetchzip
42
-
, kernel ? null
43
-
, perl
44
-
, nukeReferences
45
-
, which
46
-
, libarchive
47
-
, jq
48
-
, # Whether to build the libraries only (i.e. not the kernel module or
0
49
# nvidia-settings). Used to support 32-bit binaries on 64-bit
50
# Linux.
51
-
libsOnly ? false
52
-
, # don't include the bundled 32-bit libraries on 64-bit platforms,
53
# even if it’s in downloaded binary
54
-
disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux"
55
# 32 bit libs only version of this package
56
-
, lib32 ? null
57
# Whether to extract the GSP firmware, datacenter drivers needs to extract the
58
# firmware
59
-
, firmware ? openSha256 != null || useFabricmanager
60
# Whether the user accepts the NVIDIA Software License
61
-
, config
62
-
, acceptLicense ? config.nvidia.acceptLicense or false
63
}:
64
65
assert !libsOnly -> kernel != null;
···
97
pkgSuffix = lib.optionalString (lib.versionOlder version "304") "-pkg0";
98
i686bundled = lib.versionAtLeast version "391" && !disable32Bit;
99
100
-
libPathFor = pkgs: lib.makeLibraryPath (with pkgs; [
101
-
libdrm
102
-
xorg.libXext
103
-
xorg.libX11
104
-
xorg.libXv
105
-
xorg.libXrandr
106
-
xorg.libxcb
107
-
zlib
108
-
stdenv.cc.cc
109
-
wayland
110
-
mesa
111
-
libGL
112
-
openssl
113
-
dbus # for nvidia-powerd
114
-
]);
0
0
0
0
0
115
116
# maybe silly since we've ignored this previously and just unfree..
117
throwLicense = throw ''
···
139
builder = ./builder.sh;
140
141
src =
142
-
if !acceptLicense && (openSha256 == null) then throwLicense else
143
-
if stdenv.hostPlatform.system == "x86_64-linux" then
144
-
fetchurl
145
-
{
146
-
urls = if args ? url then [ args.url ] else [
147
-
"https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
148
-
"https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
149
-
];
150
-
sha256 = sha256_64bit;
151
-
}
0
0
0
0
152
else if stdenv.hostPlatform.system == "i686-linux" then
153
-
fetchurl
154
-
{
155
-
urls = if args ? url then [ args.url ] else [
156
-
"https://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
157
-
"https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
158
-
];
159
-
sha256 = sha256_32bit;
160
-
}
0
0
0
161
else if stdenv.hostPlatform.system == "aarch64-linux" && sha256_aarch64 != null then
162
-
fetchurl
163
-
{
164
-
urls = if args ? url then [ args.url ] else [
165
-
"https://us.download.nvidia.com/XFree86/aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
166
-
"https://download.nvidia.com/XFree86/Linux-aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
167
-
];
168
-
sha256 = sha256_aarch64;
169
-
}
170
-
else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
0
0
0
0
171
172
patches =
173
if libsOnly then
···
186
inherit (stdenv.hostPlatform) system;
187
inherit i686bundled;
188
189
-
outputs = [ "out" ]
0
190
++ lib.optional i686bundled "lib32"
191
++ lib.optional (!libsOnly) "bin"
192
++ lib.optional (!libsOnly && firmware) "firmware";
···
195
kernel = if libsOnly then null else kernel.dev;
196
kernelVersion = if libsOnly then null else kernel.modDirVersion;
197
198
-
makeFlags = lib.optionals (!libsOnly) (kernel.makeFlags ++ [
199
-
"IGNORE_PREEMPT_RT_PRESENCE=1"
200
-
"NV_BUILD_SUPPORTS_HMM=1"
201
-
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
202
-
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
203
-
]);
0
0
0
204
205
-
hardeningDisable = [ "pic" "format" ];
0
0
0
206
207
dontStrip = true;
208
dontPatchELF = true;
···
210
libPath = libPathFor pkgs;
211
libPath32 = lib.optionalString i686bundled (libPathFor pkgsi686Linux);
212
213
-
nativeBuildInputs = [ perl nukeReferences which libarchive jq ]
214
-
++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies;
0
0
0
0
0
215
216
disallowedReferences = lib.optionals (!libsOnly) [ kernel.dev ];
217
218
passthru =
219
let
220
-
fetchFromGithubOrNvidia = { owner, repo, rev, ... }@args:
0
0
0
0
0
0
221
let
222
-
args' = builtins.removeAttrs args [ "owner" "repo" "rev" ];
0
0
0
0
223
baseUrl = "https://github.com/${owner}/${repo}";
224
in
225
-
fetchzip (args' // {
226
-
urls = [
227
-
"${baseUrl}/archive/${rev}.tar.gz"
228
-
"https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2"
229
-
];
230
-
# github and nvidia use different compression algorithms,
231
-
# use an invalid file extension to force detection.
232
-
extension = "tar.??";
233
-
});
0
0
0
234
in
235
{
236
-
open = lib.mapNullable
237
-
(hash: callPackage ./open.nix {
0
238
inherit hash;
239
nvidia_x11 = self;
240
patches =
···
244
}) patches)
245
++ patchesOpen;
246
broken = brokenOpen;
247
-
})
248
-
openSha256;
249
settings =
250
if useSettings then
251
-
(if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256)
0
252
{
253
withGtk2 = preferGtk2;
254
withGtk3 = !preferGtk2;
255
fetchFromGitHub = fetchFromGithubOrNvidia;
256
-
} else { };
0
0
257
persistenced =
258
if usePersistenced then
259
-
lib.mapNullable
260
-
(hash: callPackage (import ./persistenced.nix self hash) {
0
261
fetchFromGitHub = fetchFromGithubOrNvidia;
262
-
})
263
-
persistencedSha256
264
-
else { };
0
265
fabricmanager =
266
if useFabricmanager then
267
lib.mapNullable (hash: callPackage (import ./fabricmanager.nix self hash) { }) fabricmanagerSha256
268
-
else { };
0
269
inherit persistencedVersion settingsVersion;
270
compressFirmware = false;
271
ibtSupport = ibtSupport || (lib.versionAtLeast version "530");
272
-
} // lib.optionalAttrs (!i686bundled) {
0
273
inherit lib32;
274
};
275
276
meta = with lib; {
277
homepage = "https://www.nvidia.com/object/unix.html";
278
-
description = "${if useFabricmanager then "Data Center" else "X.org"} driver and kernel module for NVIDIA cards";
0
0
279
license = licenses.unfreeRedistributable;
280
-
platforms = [ "x86_64-linux" ]
0
281
++ lib.optionals (sha256_32bit != null) [ "i686-linux" ]
282
++ lib.optionals (sha256_aarch64 != null) [ "aarch64-linux" ];
283
-
maintainers = with maintainers; [ kiskae edwtjo ];
0
0
0
284
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
285
inherit broken;
286
};
···
1
+
{
2
+
version,
3
+
url ? null,
4
+
sha256_32bit ? null,
5
+
sha256_64bit,
6
+
sha256_aarch64 ? null,
7
+
openSha256 ? null,
8
+
settingsSha256 ? null,
9
+
settingsVersion ? version,
10
+
persistencedSha256 ? null,
11
+
persistencedVersion ? version,
12
+
fabricmanagerSha256 ? null,
13
+
fabricmanagerVersion ? version,
14
+
useGLVND ? true,
15
+
useProfiles ? true,
16
+
preferGtk2 ? false,
17
+
settings32Bit ? false,
18
+
useSettings ? true,
19
+
usePersistenced ? true,
20
+
useFabricmanager ? false,
21
+
ibtSupport ? false,
22
23
+
prePatch ? null,
24
+
postPatch ? null,
25
+
patchFlags ? null,
26
+
patches ? [ ],
27
+
patchesOpen ? [ ],
28
+
preInstall ? null,
29
+
postInstall ? null,
30
+
broken ? false,
31
+
brokenOpen ? broken,
32
}@args:
33
34
+
{
35
+
lib,
36
+
stdenv,
37
+
runCommandLocal,
38
+
patchutils,
39
+
callPackage,
40
+
pkgs,
41
+
pkgsi686Linux,
42
+
fetchurl,
43
+
fetchzip,
44
+
kernel ? null,
45
+
perl,
46
+
nukeReferences,
47
+
which,
48
+
libarchive,
49
+
jq,
50
+
# Whether to build the libraries only (i.e. not the kernel module or
51
# nvidia-settings). Used to support 32-bit binaries on 64-bit
52
# Linux.
53
+
libsOnly ? false,
54
+
# don't include the bundled 32-bit libraries on 64-bit platforms,
55
# even if it’s in downloaded binary
56
+
disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux",
57
# 32 bit libs only version of this package
58
+
lib32 ? null,
59
# Whether to extract the GSP firmware, datacenter drivers needs to extract the
60
# firmware
61
+
firmware ? openSha256 != null || useFabricmanager,
62
# Whether the user accepts the NVIDIA Software License
63
+
config,
64
+
acceptLicense ? config.nvidia.acceptLicense or false,
65
}:
66
67
assert !libsOnly -> kernel != null;
···
99
pkgSuffix = lib.optionalString (lib.versionOlder version "304") "-pkg0";
100
i686bundled = lib.versionAtLeast version "391" && !disable32Bit;
101
102
+
libPathFor =
103
+
pkgs:
104
+
lib.makeLibraryPath (
105
+
with pkgs;
106
+
[
107
+
libdrm
108
+
xorg.libXext
109
+
xorg.libX11
110
+
xorg.libXv
111
+
xorg.libXrandr
112
+
xorg.libxcb
113
+
zlib
114
+
stdenv.cc.cc
115
+
wayland
116
+
mesa
117
+
libGL
118
+
openssl
119
+
dbus # for nvidia-powerd
120
+
]
121
+
);
122
123
# maybe silly since we've ignored this previously and just unfree..
124
throwLicense = throw ''
···
146
builder = ./builder.sh;
147
148
src =
149
+
if !acceptLicense && (openSha256 == null) then
150
+
throwLicense
151
+
else if stdenv.hostPlatform.system == "x86_64-linux" then
152
+
fetchurl {
153
+
urls =
154
+
if args ? url then
155
+
[ args.url ]
156
+
else
157
+
[
158
+
"https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
159
+
"https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
160
+
];
161
+
sha256 = sha256_64bit;
162
+
}
163
else if stdenv.hostPlatform.system == "i686-linux" then
164
+
fetchurl {
165
+
urls =
166
+
if args ? url then
167
+
[ args.url ]
168
+
else
169
+
[
170
+
"https://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
171
+
"https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
172
+
];
173
+
sha256 = sha256_32bit;
174
+
}
175
else if stdenv.hostPlatform.system == "aarch64-linux" && sha256_aarch64 != null then
176
+
fetchurl {
177
+
urls =
178
+
if args ? url then
179
+
[ args.url ]
180
+
else
181
+
[
182
+
"https://us.download.nvidia.com/XFree86/aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
183
+
"https://download.nvidia.com/XFree86/Linux-aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
184
+
];
185
+
sha256 = sha256_aarch64;
186
+
}
187
+
else
188
+
throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
189
190
patches =
191
if libsOnly then
···
204
inherit (stdenv.hostPlatform) system;
205
inherit i686bundled;
206
207
+
outputs =
208
+
[ "out" ]
209
++ lib.optional i686bundled "lib32"
210
++ lib.optional (!libsOnly) "bin"
211
++ lib.optional (!libsOnly && firmware) "firmware";
···
214
kernel = if libsOnly then null else kernel.dev;
215
kernelVersion = if libsOnly then null else kernel.modDirVersion;
216
217
+
makeFlags = lib.optionals (!libsOnly) (
218
+
kernel.makeFlags
219
+
++ [
220
+
"IGNORE_PREEMPT_RT_PRESENCE=1"
221
+
"NV_BUILD_SUPPORTS_HMM=1"
222
+
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
223
+
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
224
+
]
225
+
);
226
227
+
hardeningDisable = [
228
+
"pic"
229
+
"format"
230
+
];
231
232
dontStrip = true;
233
dontPatchELF = true;
···
235
libPath = libPathFor pkgs;
236
libPath32 = lib.optionalString i686bundled (libPathFor pkgsi686Linux);
237
238
+
nativeBuildInputs = [
239
+
perl
240
+
nukeReferences
241
+
which
242
+
libarchive
243
+
jq
244
+
] ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies;
245
246
disallowedReferences = lib.optionals (!libsOnly) [ kernel.dev ];
247
248
passthru =
249
let
250
+
fetchFromGithubOrNvidia =
251
+
{
252
+
owner,
253
+
repo,
254
+
rev,
255
+
...
256
+
}@args:
257
let
258
+
args' = builtins.removeAttrs args [
259
+
"owner"
260
+
"repo"
261
+
"rev"
262
+
];
263
baseUrl = "https://github.com/${owner}/${repo}";
264
in
265
+
fetchzip (
266
+
args'
267
+
// {
268
+
urls = [
269
+
"${baseUrl}/archive/${rev}.tar.gz"
270
+
"https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2"
271
+
];
272
+
# github and nvidia use different compression algorithms,
273
+
# use an invalid file extension to force detection.
274
+
extension = "tar.??";
275
+
}
276
+
);
277
in
278
{
279
+
open = lib.mapNullable (
280
+
hash:
281
+
callPackage ./open.nix {
282
inherit hash;
283
nvidia_x11 = self;
284
patches =
···
288
}) patches)
289
++ patchesOpen;
290
broken = brokenOpen;
291
+
}
292
+
) openSha256;
293
settings =
294
if useSettings then
295
+
(if settings32Bit then pkgsi686Linux.callPackage else callPackage)
296
+
(import ./settings.nix self settingsSha256)
297
{
298
withGtk2 = preferGtk2;
299
withGtk3 = !preferGtk2;
300
fetchFromGitHub = fetchFromGithubOrNvidia;
301
+
}
302
+
else
303
+
{ };
304
persistenced =
305
if usePersistenced then
306
+
lib.mapNullable (
307
+
hash:
308
+
callPackage (import ./persistenced.nix self hash) {
309
fetchFromGitHub = fetchFromGithubOrNvidia;
310
+
}
311
+
) persistencedSha256
312
+
else
313
+
{ };
314
fabricmanager =
315
if useFabricmanager then
316
lib.mapNullable (hash: callPackage (import ./fabricmanager.nix self hash) { }) fabricmanagerSha256
317
+
else
318
+
{ };
319
inherit persistencedVersion settingsVersion;
320
compressFirmware = false;
321
ibtSupport = ibtSupport || (lib.versionAtLeast version "530");
322
+
}
323
+
// lib.optionalAttrs (!i686bundled) {
324
inherit lib32;
325
};
326
327
meta = with lib; {
328
homepage = "https://www.nvidia.com/object/unix.html";
329
+
description = "${
330
+
if useFabricmanager then "Data Center" else "X.org"
331
+
} driver and kernel module for NVIDIA cards";
332
license = licenses.unfreeRedistributable;
333
+
platforms =
334
+
[ "x86_64-linux" ]
335
++ lib.optionals (sha256_32bit != null) [ "i686-linux" ]
336
++ lib.optionals (sha256_aarch64 != null) [ "aarch64-linux" ];
337
+
maintainers = with maintainers; [
338
+
kiskae
339
+
edwtjo
340
+
];
341
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
342
inherit broken;
343
};
+52
-41
pkgs/os-specific/linux/nvidia-x11/open.nix
···
1
-
{ stdenv
2
-
, lib
3
-
, fetchFromGitHub
4
-
, kernel
5
-
, nvidia_x11
6
-
, hash
7
-
, patches ? [ ]
8
-
, broken ? false
0
9
}:
10
11
-
stdenv.mkDerivation ({
12
-
pname = "nvidia-open";
13
-
version = "${kernel.version}-${nvidia_x11.version}";
0
14
15
-
src = fetchFromGitHub {
16
-
owner = "NVIDIA";
17
-
repo = "open-gpu-kernel-modules";
18
-
rev = nvidia_x11.version;
19
-
inherit hash;
20
-
};
21
22
-
inherit patches;
23
24
-
nativeBuildInputs = kernel.moduleBuildDependencies;
25
26
-
makeFlags = kernel.makeFlags ++ [
27
-
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
28
-
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
29
-
"MODLIB=$(out)/lib/modules/${kernel.modDirVersion}"
30
-
{
31
-
aarch64-linux = "TARGET_ARCH=aarch64";
32
-
x86_64-linux = "TARGET_ARCH=x86_64";
33
-
}.${stdenv.hostPlatform.system}
34
-
];
0
35
36
-
installTargets = [ "modules_install" ];
37
-
enableParallelBuilding = true;
38
39
-
meta = with lib; {
40
-
description = "NVIDIA Linux Open GPU Kernel Module";
41
-
homepage = "https://github.com/NVIDIA/open-gpu-kernel-modules";
42
-
license = with licenses; [ gpl2Plus mit ];
43
-
platforms = [ "x86_64-linux" "aarch64-linux" ];
44
-
maintainers = with maintainers; [ nickcao ];
45
-
inherit broken;
46
-
};
47
-
} // lib.optionalAttrs stdenv.hostPlatform.isAarch64 {
48
-
env.NIX_CFLAGS_COMPILE = "-fno-stack-protector";
49
-
})
0
0
0
0
0
0
0
0
···
1
+
{
2
+
stdenv,
3
+
lib,
4
+
fetchFromGitHub,
5
+
kernel,
6
+
nvidia_x11,
7
+
hash,
8
+
patches ? [ ],
9
+
broken ? false,
10
}:
11
12
+
stdenv.mkDerivation (
13
+
{
14
+
pname = "nvidia-open";
15
+
version = "${kernel.version}-${nvidia_x11.version}";
16
17
+
src = fetchFromGitHub {
18
+
owner = "NVIDIA";
19
+
repo = "open-gpu-kernel-modules";
20
+
rev = nvidia_x11.version;
21
+
inherit hash;
22
+
};
23
24
+
inherit patches;
25
26
+
nativeBuildInputs = kernel.moduleBuildDependencies;
27
28
+
makeFlags = kernel.makeFlags ++ [
29
+
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
30
+
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
31
+
"MODLIB=$(out)/lib/modules/${kernel.modDirVersion}"
32
+
{
33
+
aarch64-linux = "TARGET_ARCH=aarch64";
34
+
x86_64-linux = "TARGET_ARCH=x86_64";
35
+
}
36
+
.${stdenv.hostPlatform.system}
37
+
];
38
39
+
installTargets = [ "modules_install" ];
40
+
enableParallelBuilding = true;
41
42
+
meta = with lib; {
43
+
description = "NVIDIA Linux Open GPU Kernel Module";
44
+
homepage = "https://github.com/NVIDIA/open-gpu-kernel-modules";
45
+
license = with licenses; [
46
+
gpl2Plus
47
+
mit
48
+
];
49
+
platforms = [
50
+
"x86_64-linux"
51
+
"aarch64-linux"
52
+
];
53
+
maintainers = with maintainers; [ nickcao ];
54
+
inherit broken;
55
+
};
56
+
}
57
+
// lib.optionalAttrs stdenv.hostPlatform.isAarch64 {
58
+
env.NIX_CFLAGS_COMPILE = "-fno-stack-protector";
59
+
}
60
+
)
+92
-57
pkgs/os-specific/linux/nvidia-x11/settings.nix
···
1
nvidia_x11: sha256:
2
3
-
{ stdenv
4
-
, lib
5
-
, fetchFromGitHub
6
-
, fetchpatch
7
-
, pkg-config
8
-
, m4
9
-
, jansson
10
-
, gtk2
11
-
, dbus
12
-
, vulkan-headers
13
-
, gtk3
14
-
, libXv
15
-
, libXrandr
16
-
, libXext
17
-
, libXxf86vm
18
-
, libvdpau
19
-
, librsvg
20
-
, libglvnd
21
-
, wrapGAppsHook3
22
-
, addDriverRunpath
23
-
, withGtk2 ? false
24
-
, withGtk3 ? true
0
25
}:
26
27
let
···
35
meta = with lib; {
36
homepage = "https://www.nvidia.com/object/unix.html";
37
platforms = nvidia_x11.meta.platforms;
38
-
maintainers = with maintainers; [ abbradar aidalgol ];
0
0
0
39
};
40
41
libXNVCtrl = stdenv.mkDerivation {
···
43
version = nvidia_x11.settingsVersion;
44
inherit src;
45
46
-
buildInputs = [ libXrandr libXext ];
0
0
0
47
48
preBuild = ''
49
cd src/libXNVCtrl
···
57
58
patches = [
59
# Patch the Makefile to also produce a shared library.
60
-
(if lib.versionOlder nvidia_x11.settingsVersion "400" then ./libxnvctrl-build-shared-3xx.patch
61
-
else ./libxnvctrl-build-shared.patch)
0
0
0
0
62
];
63
64
installPhase = ''
···
79
};
80
81
runtimeDependencies = [
82
-
libglvnd libXrandr libXv
0
0
83
];
84
85
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
···
92
93
inherit src;
94
95
-
patches = lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440")
96
-
(fetchpatch {
97
# fixes "multiple definition of `VDPAUDeviceFunctions'" linking errors
98
url = "https://github.com/NVIDIA/nvidia-settings/commit/a7c1f5fce6303a643fadff7d85d59934bd0cf6b6.patch";
99
hash = "sha256-ZwF3dRTYt/hO8ELg9weoz1U/XcU93qiJL2d1aq1Jlak=";
100
})
101
-
++ lib.optional
102
-
((lib.versionAtLeast nvidia_x11.settingsVersion "515.43.04")
103
-
&& (lib.versionOlder nvidia_x11.settingsVersion "545.29"))
104
-
(fetchpatch {
105
-
# fix wayland support for compositors that use wl_output version 4
106
-
url = "https://github.com/NVIDIA/nvidia-settings/pull/99/commits/2e0575197e2b3247deafd2a48f45afc038939a06.patch";
107
-
hash = "sha256-wKuO5CUTUuwYvsP46Pz+6fI0yxLNpZv8qlbL0TFkEFE=";
108
-
});
0
0
109
110
postPatch = lib.optionalString nvidia_x11.useProfiles ''
111
sed -i 's,/usr/share/nvidia/,${nvidia_x11.bin}/share/nvidia/,g' src/gtk+-2.x/ctkappprofile.c
···
122
fi
123
'';
124
125
-
nativeBuildInputs = [ pkg-config m4 addDriverRunpath ]
126
-
++ lib.optionals withGtk3 [ wrapGAppsHook3 ];
0
0
0
127
128
-
buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 dbus vulkan-headers ]
0
0
0
0
0
0
0
0
0
0
0
129
++ lib.optionals (withGtk2 || lib.versionOlder nvidia_x11.settingsVersion "525.53") [ gtk2 ]
130
-
++ lib.optionals withGtk3 [ gtk3 librsvg ];
0
0
0
131
132
installFlags = [ "PREFIX=$(out)" ];
133
134
-
postInstall = lib.optionalString (!withGtk2) ''
135
-
rm -f $out/lib/libnvidia-gtk2.so.*
136
-
'' + lib.optionalString (!withGtk3) ''
137
-
rm -f $out/lib/libnvidia-gtk3.so.*
138
-
'' + ''
139
-
# Install the desktop file and icon.
140
-
# The template has substitution variables intended to be replaced resulting
141
-
# in absolute paths. Because absolute paths break after the desktop file is
142
-
# copied by a desktop environment, make Exec and Icon be just a name.
143
-
sed -i doc/nvidia-settings.desktop \
144
-
-e "s|^Exec=.*$|Exec=nvidia-settings|" \
145
-
-e "s|^Icon=.*$|Icon=nvidia-settings|" \
146
-
-e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g"
147
-
install doc/nvidia-settings.desktop -D -t $out/share/applications/
148
-
install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/
149
-
'';
0
0
0
150
151
binaryName = if withGtk3 then ".nvidia-settings-wrapped" else "nvidia-settings";
152
postFixup = ''
···
1
nvidia_x11: sha256:
2
3
+
{
4
+
stdenv,
5
+
lib,
6
+
fetchFromGitHub,
7
+
fetchpatch,
8
+
pkg-config,
9
+
m4,
10
+
jansson,
11
+
gtk2,
12
+
dbus,
13
+
vulkan-headers,
14
+
gtk3,
15
+
libXv,
16
+
libXrandr,
17
+
libXext,
18
+
libXxf86vm,
19
+
libvdpau,
20
+
librsvg,
21
+
libglvnd,
22
+
wrapGAppsHook3,
23
+
addDriverRunpath,
24
+
withGtk2 ? false,
25
+
withGtk3 ? true,
26
}:
27
28
let
···
36
meta = with lib; {
37
homepage = "https://www.nvidia.com/object/unix.html";
38
platforms = nvidia_x11.meta.platforms;
39
+
maintainers = with maintainers; [
40
+
abbradar
41
+
aidalgol
42
+
];
43
};
44
45
libXNVCtrl = stdenv.mkDerivation {
···
47
version = nvidia_x11.settingsVersion;
48
inherit src;
49
50
+
buildInputs = [
51
+
libXrandr
52
+
libXext
53
+
];
54
55
preBuild = ''
56
cd src/libXNVCtrl
···
64
65
patches = [
66
# Patch the Makefile to also produce a shared library.
67
+
(
68
+
if lib.versionOlder nvidia_x11.settingsVersion "400" then
69
+
./libxnvctrl-build-shared-3xx.patch
70
+
else
71
+
./libxnvctrl-build-shared.patch
72
+
)
73
];
74
75
installPhase = ''
···
90
};
91
92
runtimeDependencies = [
93
+
libglvnd
94
+
libXrandr
95
+
libXv
96
];
97
98
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
···
105
106
inherit src;
107
108
+
patches =
109
+
lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") (fetchpatch {
110
# fixes "multiple definition of `VDPAUDeviceFunctions'" linking errors
111
url = "https://github.com/NVIDIA/nvidia-settings/commit/a7c1f5fce6303a643fadff7d85d59934bd0cf6b6.patch";
112
hash = "sha256-ZwF3dRTYt/hO8ELg9weoz1U/XcU93qiJL2d1aq1Jlak=";
113
})
114
+
++ lib.optional
115
+
(
116
+
(lib.versionAtLeast nvidia_x11.settingsVersion "515.43.04")
117
+
&& (lib.versionOlder nvidia_x11.settingsVersion "545.29")
118
+
)
119
+
(fetchpatch {
120
+
# fix wayland support for compositors that use wl_output version 4
121
+
url = "https://github.com/NVIDIA/nvidia-settings/pull/99/commits/2e0575197e2b3247deafd2a48f45afc038939a06.patch";
122
+
hash = "sha256-wKuO5CUTUuwYvsP46Pz+6fI0yxLNpZv8qlbL0TFkEFE=";
123
+
});
124
125
postPatch = lib.optionalString nvidia_x11.useProfiles ''
126
sed -i 's,/usr/share/nvidia/,${nvidia_x11.bin}/share/nvidia/,g' src/gtk+-2.x/ctkappprofile.c
···
137
fi
138
'';
139
140
+
nativeBuildInputs = [
141
+
pkg-config
142
+
m4
143
+
addDriverRunpath
144
+
] ++ lib.optionals withGtk3 [ wrapGAppsHook3 ];
145
146
+
buildInputs =
147
+
[
148
+
jansson
149
+
libXv
150
+
libXrandr
151
+
libXext
152
+
libXxf86vm
153
+
libvdpau
154
+
nvidia_x11
155
+
dbus
156
+
vulkan-headers
157
+
]
158
++ lib.optionals (withGtk2 || lib.versionOlder nvidia_x11.settingsVersion "525.53") [ gtk2 ]
159
+
++ lib.optionals withGtk3 [
160
+
gtk3
161
+
librsvg
162
+
];
163
164
installFlags = [ "PREFIX=$(out)" ];
165
166
+
postInstall =
167
+
lib.optionalString (!withGtk2) ''
168
+
rm -f $out/lib/libnvidia-gtk2.so.*
169
+
''
170
+
+ lib.optionalString (!withGtk3) ''
171
+
rm -f $out/lib/libnvidia-gtk3.so.*
172
+
''
173
+
+ ''
174
+
# Install the desktop file and icon.
175
+
# The template has substitution variables intended to be replaced resulting
176
+
# in absolute paths. Because absolute paths break after the desktop file is
177
+
# copied by a desktop environment, make Exec and Icon be just a name.
178
+
sed -i doc/nvidia-settings.desktop \
179
+
-e "s|^Exec=.*$|Exec=nvidia-settings|" \
180
+
-e "s|^Icon=.*$|Icon=nvidia-settings|" \
181
+
-e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g"
182
+
install doc/nvidia-settings.desktop -D -t $out/share/applications/
183
+
install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/
184
+
'';
185
186
binaryName = if withGtk3 then ".nvidia-settings-wrapped" else "nvidia-settings";
187
postFixup = ''