Skip to content

Commit 51fabd1

Browse files
committed
nixos/nvidia: run nixfmt on nvidia related files
1 parent ba556d1 commit 51fabd1

File tree

5 files changed

+483
-349
lines changed

5 files changed

+483
-349
lines changed

nixos/modules/hardware/video/nvidia.nix

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,23 @@ in
9292
information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux
9393
'';
9494

95-
modesetting.enable = lib.mkEnableOption ''
96-
kernel modesetting when using the NVIDIA proprietary driver.
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-
};
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+
};
110112

111113
prime.nvidiaBusId = lib.mkOption {
112114
type = busIDType;
@@ -266,14 +268,16 @@ in
266268
'';
267269
};
268270

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-
};
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+
};
277281

278282
videoAcceleration =
279283
(lib.mkEnableOption ''
@@ -323,7 +327,9 @@ in
323327
softdep nvidia post: nvidia-uvm
324328
'';
325329
};
326-
systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ];
330+
systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [
331+
"L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin"
332+
];
327333
services.udev.extraRules = ''
328334
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
329335
KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'"
@@ -622,7 +628,9 @@ in
622628
# If requested enable modesetting via kernel parameters.
623629
kernelParams =
624630
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"
631+
++ lib.optional (
632+
(offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545"
633+
) "nvidia-drm.fbdev=1"
626634
++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
627635
++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1"
628636
++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off";
@@ -683,7 +691,9 @@ in
683691
TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
684692
DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
685693
};
686-
nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (fabricManagerConfDefaults // cfg.datacenter.settings);
694+
nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (
695+
fabricManagerConfDefaults // cfg.datacenter.settings
696+
);
687697
in
688698
"${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}";
689699
LimitCORE = "infinity";

pkgs/os-specific/linux/nvidia-x11/default.nix

Lines changed: 114 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
1-
{ lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }:
1+
{
2+
lib,
3+
callPackage,
4+
fetchFromGitHub,
5+
fetchgit,
6+
fetchpatch,
7+
stdenv,
8+
pkgsi686Linux,
9+
}:
210

311
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-
};
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+
};
1224

13-
kernel = callPackage # a hacky way of extracting parameters from callPackage
14-
({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { };
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+
) { };
1534

16-
selectHighestVersion = a: b: if lib.versionOlder a.version b.version
17-
then b
18-
else a;
35+
selectHighestVersion = a: b: if lib.versionOlder a.version b.version then b else a;
1936

2037
# 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
2138
rcu_patch = fetchpatch {
@@ -25,7 +42,7 @@ let
2542

2643
# Fixes drm device not working with linux 6.12
2744
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/712
28-
drm_fop_flags_linux_612_patch = fetchpatch {
45+
drm_fop_flags_linux_612_patch = fetchpatch {
2946
url = "https://github.com/Binary-Eater/open-gpu-kernel-modules/commit/8ac26d3c66ea88b0f80504bdd1e907658b41609d.patch";
3047
hash = "sha256-+SfIu3uYNQCf/KXhv4PWvruTVKQSh4bgU1moePhe57U=";
3148
};
@@ -136,85 +153,89 @@ rec {
136153
};
137154

138155
# 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=";
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+
'';
145193
};
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 ";
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-
};
175194

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=";
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;
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+
'';
183240
};
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-
};
220241
}

0 commit comments

Comments
 (0)