-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
nixos: hardware.nvidia.package option for selecting nvidia package #49703
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,34 +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 "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; | ||
|
|
@@ -149,6 +132,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 = mkIf enabled { | ||
|
|
@@ -228,9 +221,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 ] | ||
| ++ filter (p: p != null) [ nvidia_x11.persistenced ]; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should show in the error message already what package the user should choose based on their previous setting. We have all the information we need to make a better error message and ease the transition for users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess it should be fine to simply add one "legacy" example and maybe also one "beta" example.