summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2021-01-30 22:08:37 -0500
committerGitHub <noreply@github.com>2021-01-30 22:08:37 -0500
commit161b9b24365cff3c94f1c2d3eb5a5e13c722d04a (patch)
tree90632275e31c06dd389ab990795a64fca178504b /nixos
parent638e784bda77159138c7057d426cf8a0870da98f (diff)
parent450cb04f16cc2214c2a298fe26bb4c306cf84fb3 (diff)
Merge pull request #99323 from eadwu/nvidia/hardware.nvidia.package
nixos: hardware.nvidia.package option for selecting nvidia package
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/hardware/video/nvidia.nix51
1 files changed, 21 insertions, 30 deletions
diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix
index 72eb9fcfaa60..97accc7b99a0 100644
--- a/nixos/modules/hardware/video/nvidia.nix
+++ b/nixos/modules/hardware/video/nvidia.nix
@@ -5,36 +5,17 @@
with lib;
let
-
- drivers = config.services.xserver.videoDrivers;
-
- # FIXME: should introduce an option like
- # ‘hardware.video.nvidia.package’ for overriding the default NVIDIA
- # driver.
- nvidiaForKernel = kernelPackages:
- if elem "nvidia" drivers then
- kernelPackages.nvidia_x11
- else if elem "nvidiaBeta" drivers then
- kernelPackages.nvidia_x11_beta
- else if elem "nvidiaVulkanBeta" drivers then
- kernelPackages.nvidia_x11_vulkan_beta
- else if elem "nvidiaLegacy304" drivers then
- kernelPackages.nvidia_x11_legacy304
- else if elem "nvidiaLegacy340" drivers then
- kernelPackages.nvidia_x11_legacy340
- else if elem "nvidiaLegacy390" drivers then
- kernelPackages.nvidia_x11_legacy390
- else null;
-
- nvidia_x11 = nvidiaForKernel config.boot.kernelPackages;
- nvidia_libs32 =
- if versionOlder nvidia_x11.version "391" then
- ((nvidiaForKernel pkgs.pkgsi686Linux.linuxPackages).override { libsOnly = true; kernel = null; }).out
- else
- (nvidiaForKernel config.boot.kernelPackages).lib32;
+ nvidia_x11 = let
+ drivers = config.services.xserver.videoDrivers;
+ isDeprecated = str: (hasPrefix "nvidia" str) && (str != "nvidia");
+ hasDeprecated = drivers: any isDeprecated drivers;
+ in if (hasDeprecated drivers) then
+ throw ''
+ Selecting an nvidia driver has been modified for NixOS 19.03. The version is now set using `hardware.nvidia.package`.
+ ''
+ else if (elem "nvidia" drivers) then cfg.package else null;
enabled = nvidia_x11 != null;
-
cfg = config.hardware.nvidia;
pCfg = cfg.prime;
@@ -170,6 +151,16 @@ in
GPUs stay awake even during headless mode.
'';
};
+
+ hardware.nvidia.package = lib.mkOption {
+ type = lib.types.package;
+ default = config.boot.kernelPackages.nvidiaPackages.stable;
+ defaultText = "config.boot.kernelPackages.nvidiaPackages.stable";
+ description = ''
+ The NVIDIA X11 derivation to use.
+ '';
+ example = "config.boot.kernelPackages.nvidiaPackages.legacy340";
+ };
};
config = let
@@ -271,9 +262,9 @@ in
};
hardware.opengl.package = mkIf (!offloadCfg.enable) nvidia_x11.out;
- hardware.opengl.package32 = mkIf (!offloadCfg.enable) nvidia_libs32;
+ hardware.opengl.package32 = mkIf (!offloadCfg.enable) nvidia_x11.lib32;
hardware.opengl.extraPackages = optional offloadCfg.enable nvidia_x11.out;
- hardware.opengl.extraPackages32 = optional offloadCfg.enable nvidia_libs32;
+ hardware.opengl.extraPackages32 = optional offloadCfg.enable nvidia_x11.lib32;
environment.systemPackages = [ nvidia_x11.bin nvidia_x11.settings ]
++ optionals nvidiaPersistencedEnabled [ nvidia_x11.persistenced ];