diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 2792f3f2ad8be1e..9bef55f4fc48164 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -137,6 +137,8 @@ Processes also now run as a dynamically allocated user by default instead of root. +- The nvidia driver no longer defaults to the proprietary driver starting with version 560. You will need to manually set `hardware.nvidia.open` to select the proprietary or open driver. + - `singularity-tools` have the `storeDir` argument removed from its override interface and use `builtins.storeDir` instead. - Two build helpers in `singularity-tools`, i.e., `mkLayer` and `shellScript`, are deprecated, as they are no longer involved in image-building. Maintainers will remove them in future releases. diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index ee8904da8572fb8..9855d3d0ad7845b 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -18,6 +18,7 @@ let busIDType = lib.types.strMatching "([[:print:]]+[\:\@][0-9]{1,3}\:[0-9]{1,2}\:[0-9])?"; ibtSupport = cfg.open || (nvidia_x11.ibtSupport or false); settingsFormat = pkgs.formats.keyValue { }; + isOpen = cfg.open == true; in { options = { @@ -254,10 +255,14 @@ in ''; }; - open = lib.mkEnableOption '' - the open source NVIDIA kernel module - '' // { - defaultText = lib.literalExpression ''lib.versionAtLeast config.hardware.nvidia.package.version "560"''; + open = lib.mkOption { + default = null; + example = true; + description = "Whether to enable the open source NVIDIA kernel module."; + type = lib.types.nullOr lib.types.bool; + defaultText = lib.literalExpression '' + if lib.versionOlder config.hardware.nvidia.package.version "560" then false else null + ''; }; }; }; @@ -308,7 +313,7 @@ in }; environment.systemPackages = [ nvidia_x11.bin ]; - hardware.nvidia.open = lib.mkDefault (lib.versionAtLeast nvidia_x11.version "560"); + hardware.nvidia.open = lib.mkIf (lib.versionOlder nvidia_x11.version "560") (lib.mkDefault false); }) # X11 @@ -367,8 +372,13 @@ in } { - assertion = cfg.open -> (cfg.package ? open && cfg.package ? firmware); - message = "This version of NVIDIA driver does not provide a corresponding opensource kernel driver"; + assertion = isOpen -> (cfg.package ? open && cfg.package ? firmware); + message = "This version of NVIDIA driver does not provide a corresponding opensource kernel driver."; + } + + { + assertion = cfg.open != null; + message = "You must specify which variant of the nvidia kernel driver to use."; } { @@ -555,7 +565,7 @@ in services.dbus.packages = lib.optional cfg.dynamicBoost.enable nvidia_x11.bin; - hardware.firmware = lib.optional (cfg.open || lib.versionAtLeast nvidia_x11.version "555") nvidia_x11.firmware; + hardware.firmware = lib.optional (isOpen || lib.versionAtLeast nvidia_x11.version "555") nvidia_x11.firmware; systemd.tmpfiles.rules = [ @@ -570,7 +580,7 @@ in "L+ /run/nvidia-docker/extras/bin/nvidia-persistenced - - - - ${nvidia_x11.persistenced}/origBin/nvidia-persistenced"; boot = { - extraModulePackages = if cfg.open then [ nvidia_x11.open ] else [ nvidia_x11.bin ]; + extraModulePackages = if isOpen then [ nvidia_x11.open ] else [ nvidia_x11.bin ]; # nvidia-uvm is required by CUDA applications. kernelModules = lib.optionals config.services.xserver.enable [ @@ -581,14 +591,14 @@ in # With the open driver, nvidia-uvm does not automatically load as # a softdep of the nvidia module, so we explicitly load it for now. # See https://github.com/NixOS/nixpkgs/issues/334180 - ++ lib.optionals (config.services.xserver.enable && cfg.open) [ "nvidia_uvm" ]; + ++ lib.optionals (config.services.xserver.enable && isOpen) [ "nvidia_uvm" ]; # 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 cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1" - ++ lib.optional cfg.open "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" + ++ lib.optional isOpen "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" ++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off"; # enable finegrained power management