Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/nvidia: add nvidia_dc_565 drivers #363367

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

- `nodePackages.copy-webpack-plugin` has been removed, as it should be installed in projects that use it instead.

- `linuxPackages.nvidiaPackages.dc_520` has been removed since it is marked broken and there are better newer alternatives.

- `racket_7_9` has been removed, as it is insecure. It is recommended to use Racket 8 instead.

- `ente-auth` now uses the name `enteauth` for its binary. The previous name was `ente_auth`.
Expand Down
64 changes: 37 additions & 27 deletions nixos/modules/hardware/video/nvidia.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,23 @@ in
information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux
'';

modesetting.enable = lib.mkEnableOption ''
kernel modesetting when using the NVIDIA proprietary driver.

Enabling this fixes screen tearing when using Optimus via PRIME (see
{option}`hardware.nvidia.prime.sync.enable`. This is not enabled
by default because it is not officially supported by NVIDIA and would not
work with SLI.

Enabling this and using version 545 or newer of the proprietary NVIDIA
driver causes it to provide its own framebuffer device, which can cause
Wayland compositors to work when they otherwise wouldn't.
'' // {
default = lib.versionAtLeast cfg.package.version "535";
defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\"";
};
modesetting.enable =
lib.mkEnableOption ''
kernel modesetting when using the NVIDIA proprietary driver.

Enabling this fixes screen tearing when using Optimus via PRIME (see
{option}`hardware.nvidia.prime.sync.enable`. This is not enabled
by default because it is not officially supported by NVIDIA and would not
work with SLI.

Enabling this and using version 545 or newer of the proprietary NVIDIA
driver causes it to provide its own framebuffer device, which can cause
Wayland compositors to work when they otherwise wouldn't.
''
// {
default = lib.versionAtLeast cfg.package.version "535";
defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\"";
};

prime.nvidiaBusId = lib.mkOption {
type = busIDType;
Expand Down Expand Up @@ -266,14 +268,16 @@ in
'';
};

gsp.enable = lib.mkEnableOption ''
the GPU System Processor (GSP) on the video card
'' // {
default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555";
defaultText = lib.literalExpression ''
config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555"
'';
};
gsp.enable =
lib.mkEnableOption ''
the GPU System Processor (GSP) on the video card
''
// {
default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555";
defaultText = lib.literalExpression ''
config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555"
'';
};

videoAcceleration =
(lib.mkEnableOption ''
Expand All @@ -300,7 +304,7 @@ in
message = "You cannot configure both X11 and Data Center drivers at the same time.";
}
{
assertion = cfg.open != null;
assertion = cfg.open != null || cfg.datacenter.enable;
edwtjo marked this conversation as resolved.
Show resolved Hide resolved
message = ''
You must configure `hardware.nvidia.open` on NVIDIA driver versions >= 560.
It is suggested to use the open source kernel modules on Turing or later GPUs (RTX series, GTX 16xx), and the closed source modules otherwise.
Expand All @@ -323,7 +327,9 @@ in
softdep nvidia post: nvidia-uvm
'';
};
systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ];
systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [
"L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin"
];
services.udev.extraRules = ''
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'"
Expand Down Expand Up @@ -622,7 +628,9 @@ in
# If requested enable modesetting via kernel parameters.
kernelParams =
lib.optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1"
++ lib.optional ((offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545") "nvidia-drm.fbdev=1"
++ lib.optional (
(offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545"
) "nvidia-drm.fbdev=1"
++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1"
++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off";
Expand Down Expand Up @@ -683,7 +691,9 @@ in
TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch";
};
nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (fabricManagerConfDefaults // cfg.datacenter.settings);
nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (
fabricManagerConfDefaults // cfg.datacenter.settings
);
in
"${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}";
LimitCORE = "infinity";
Expand Down
233 changes: 126 additions & 107 deletions pkgs/os-specific/linux/nvidia-x11/default.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
{ lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }:
{
lib,
callPackage,
fetchFromGitHub,
fetchgit,
fetchpatch,
stdenv,
pkgsi686Linux,
}:

let
generic = args: let
imported = import ./generic.nix args;
in callPackage imported {
lib32 = (pkgsi686Linux.callPackage imported {
libsOnly = true;
kernel = null;
}).out;
};
generic =
args:
let
imported = import ./generic.nix args;
in
callPackage imported {
lib32 =
(pkgsi686Linux.callPackage imported {
libsOnly = true;
kernel = null;
}).out;
};

kernel = callPackage # a hacky way of extracting parameters from callPackage
({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { };
kernel =
# a hacky way of extracting parameters from callPackage
callPackage (
{
kernel,
libsOnly ? false,
}:
if libsOnly then { } else kernel
) { };

selectHighestVersion = a: b: if lib.versionOlder a.version b.version
then b
else a;
selectHighestVersion = a: b: if lib.versionOlder a.version b.version then b else a;

# 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
rcu_patch = fetchpatch {
Expand All @@ -25,7 +42,7 @@ let

# Fixes drm device not working with linux 6.12
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/712
drm_fop_flags_linux_612_patch = fetchpatch {
drm_fop_flags_linux_612_patch = fetchpatch {
url = "https://github.com/Binary-Eater/open-gpu-kernel-modules/commit/8ac26d3c66ea88b0f80504bdd1e907658b41609d.patch";
hash = "sha256-+SfIu3uYNQCf/KXhv4PWvruTVKQSh4bgU1moePhe57U=";
};
Expand Down Expand Up @@ -83,20 +100,7 @@ rec {
};

# data center driver compatible with current default cudaPackages
dc = dc_520;
dc_520 = generic rec {
version = "520.61.05";
edwtjo marked this conversation as resolved.
Show resolved Hide resolved
url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
sha256_64bit = "sha256-EPYWZwOur/6iN/otDMrNDpNXr1mzu8cIqQl8lXhQlzU==";
fabricmanagerSha256 = "sha256-o8Kbmkg7qczKQclaGvEyXNzEOWq9ZpQZn9syeffnEiE==";
useSettings = false;
usePersistenced = false;
useFabricmanager = true;

patches = [ rcu_patch ];

broken = kernel.kernelAtLeast "6.5";
};
dc = dc_565;

dc_535 = generic rec {
version = "535.154.05";
Expand All @@ -111,6 +115,17 @@ rec {
patches = [ rcu_patch ];
};

dc_565 = generic rec {
version = "565.57.01";
url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
sha256_64bit = "sha256-buvpTlheOF6IBPWnQVLfQUiHv4GcwhvZW3Ks0PsYLHo=";
persistencedSha256 = "sha256-hdszsACWNqkCh8G4VBNitDT85gk9gJe1BlQ8LdrYIkg=";
fabricmanagerSha256 = "sha256-umhyehddbQ9+xhhoiKC7SOSVxscA5pcnqvkQOOLIdsM=";
useSettings = false;
usePersistenced = true;
useFabricmanager = true;
};

# Update note:
# If you add a legacy driver here, also update `top-level/linux-kernels.nix`,
# adding to the `nvidia_x11_legacy*` entries.
Expand All @@ -136,85 +151,89 @@ rec {
};

# Last one supporting x86
legacy_390 = let
# Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
aurPatches = fetchgit {
url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3";
hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E=";
legacy_390 =
let
# Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
aurPatches = fetchgit {
url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
rev = "ebb48c240ce329e89ad3b59e78c8c708f46f27b3";
hash = "sha256-AGx3/EQ81awBMs6rrXTGWJmyq+UjBCPp6/9z1BQBB9E=";
};
patchset = [
"kernel-4.16+-memory-encryption.patch"
"kernel-6.2.patch"
"kernel-6.3.patch"
"kernel-6.4.patch"
"kernel-6.5.patch"
"kernel-6.6.patch"
"kernel-6.8.patch"
"gcc-14.patch"
"kernel-6.10.patch"
];
in
generic {
version = "390.157";
sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k=";
sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo=";
settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw=";
persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns=";

patches = map (patch: "${aurPatches}/${patch}") patchset;
broken = kernel.kernelAtLeast "6.11 ";

# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
postInstall = ''
mv $out/lib/tls/* $out/lib
rmdir $out/lib/tls
'';
};
patchset = [
"kernel-4.16+-memory-encryption.patch"
"kernel-6.2.patch"
"kernel-6.3.patch"
"kernel-6.4.patch"
"kernel-6.5.patch"
"kernel-6.6.patch"
"kernel-6.8.patch"
"gcc-14.patch"
"kernel-6.10.patch"
];
in generic {
version = "390.157";
sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k=";
sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo=";
settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw=";
persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns=";

patches = map (patch: "${aurPatches}/${patch}") patchset;
broken = kernel.kernelAtLeast "6.11 ";

# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
postInstall = ''
mv $out/lib/tls/* $out/lib
rmdir $out/lib/tls
'';
};

legacy_340 = let
# Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms
aurPatches = fetchFromGitHub {
owner = "archlinux-jerry";
repo = "nvidia-340xx";
rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90";
hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo=";
legacy_340 =
let
# Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms
aurPatches = fetchFromGitHub {
owner = "archlinux-jerry";
repo = "nvidia-340xx";
rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90";
hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo=";
};
patchset = [
"0001-kernel-5.7.patch"
"0002-kernel-5.8.patch"
"0003-kernel-5.9.patch"
"0004-kernel-5.10.patch"
"0005-kernel-5.11.patch"
"0006-kernel-5.14.patch"
"0007-kernel-5.15.patch"
"0008-kernel-5.16.patch"
"0009-kernel-5.17.patch"
"0010-kernel-5.18.patch"
"0011-kernel-6.0.patch"
"0012-kernel-6.2.patch"
"0013-kernel-6.3.patch"
"0014-kernel-6.5.patch"
"0015-kernel-6.6.patch"
];
in
generic {
version = "340.108";
sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0";
sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6";
settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34";
persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn";
useGLVND = false;

broken = kernel.kernelAtLeast "6.7";
patches = map (patch: "${aurPatches}/${patch}") patchset;

# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
postInstall = ''
mv $out/lib/tls/* $out/lib
rmdir $out/lib/tls
'';
};
patchset = [
"0001-kernel-5.7.patch"
"0002-kernel-5.8.patch"
"0003-kernel-5.9.patch"
"0004-kernel-5.10.patch"
"0005-kernel-5.11.patch"
"0006-kernel-5.14.patch"
"0007-kernel-5.15.patch"
"0008-kernel-5.16.patch"
"0009-kernel-5.17.patch"
"0010-kernel-5.18.patch"
"0011-kernel-6.0.patch"
"0012-kernel-6.2.patch"
"0013-kernel-6.3.patch"
"0014-kernel-6.5.patch"
"0015-kernel-6.6.patch"
];
in generic {
version = "340.108";
sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0";
sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6";
settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34";
persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn";
useGLVND = false;

broken = kernel.kernelAtLeast "6.7";
patches = map (patch: "${aurPatches}/${patch}") patchset;

# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
postInstall = ''
mv $out/lib/tls/* $out/lib
rmdir $out/lib/tls
'';
};
}
Loading
Loading