diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix
index 88ae088bb28..295180d2b64 100644
--- a/nixos/modules/hardware/video/nvidia.nix
+++ b/nixos/modules/hardware/video/nvidia.nix
@@ -34,7 +34,8 @@ let
enabled = nvidia_x11 != null;
cfg = config.hardware.nvidia;
- syncCfg = cfg.prime.sync;
+ pCfg = cfg.prime;
+ syncCfg = pCfg.sync;
in
{
@@ -42,8 +43,8 @@ in
[
(mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "enable" ] [ "hardware" "nvidia" "prime" "sync" "enable" ])
(mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "allowExternalGpu" ] [ "hardware" "nvidia" "prime" "sync" "allowExternalGpu" ])
- (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "nvidiaBusId" ] [ "hardware" "nvidia" "prime" "sync" "nvidiaBusId" ])
- (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "intelBusId" ] [ "hardware" "nvidia" "prime" "sync" "intelBusId" ])
+ (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "nvidiaBusId" ] [ "hardware" "nvidia" "prime" "nvidiaBusId" ])
+ (mkRenamedOptionModule [ "hardware" "nvidia" "optimus_prime" "intelBusId" ] [ "hardware" "nvidia" "prime" "intelBusId" ])
];
options = {
@@ -60,6 +61,26 @@ in
'';
};
+ hardware.nvidia.prime.nvidiaBusId = mkOption {
+ type = types.str;
+ default = "";
+ example = "PCI:1:0:0";
+ description = ''
+ Bus ID of the NVIDIA GPU. You can find it using lspci; for example if lspci
+ shows the NVIDIA GPU at "01:00.0", set this option to "PCI:1:0:0".
+ '';
+ };
+
+ hardware.nvidia.prime.intelBusId = mkOption {
+ type = types.str;
+ default = "";
+ example = "PCI:0:2:0";
+ description = ''
+ Bus ID of the Intel GPU. You can find it using lspci; for example if lspci
+ shows the Intel GPU at "00:02.0", set this option to "PCI:0:2:0".
+ '';
+ };
+
hardware.nvidia.prime.sync.enable = mkOption {
type = types.bool;
default = false;
@@ -74,8 +95,8 @@ in
be the only driver there.
If this is enabled, then the bus IDs of the NVIDIA and Intel GPUs have to be
- specified ( and
- ).
+ specified ( and
+ ).
If you enable this, you may want to also enable kernel modesetting for the
NVIDIA driver () in order
@@ -94,26 +115,6 @@ in
Configure X to allow external NVIDIA GPUs when using optimus.
'';
};
-
- hardware.nvidia.prime.sync.nvidiaBusId = mkOption {
- type = types.str;
- default = "";
- example = "PCI:1:0:0";
- description = ''
- Bus ID of the NVIDIA GPU. You can find it using lspci; for example if lspci
- shows the NVIDIA GPU at "01:00.0", set this option to "PCI:1:0:0".
- '';
- };
-
- hardware.nvidia.prime.sync.intelBusId = mkOption {
- type = types.str;
- default = "";
- example = "PCI:0:2:0";
- description = ''
- Bus ID of the Intel GPU. You can find it using lspci; for example if lspci
- shows the Intel GPU at "00:02.0", set this option to "PCI:0:2:0".
- '';
- };
};
config = mkIf enabled {
@@ -125,7 +126,7 @@ in
{
assertion = !syncCfg.enable ||
- (syncCfg.nvidiaBusId != "" && syncCfg.intelBusId != "");
+ (pCfg.nvidiaBusId != "" && pCfg.intelBusId != "");
message = ''
When NVIDIA Optimus via PRIME is enabled, the GPU bus IDs must configured.
'';
@@ -149,7 +150,7 @@ in
modules = [ nvidia_x11.bin ];
deviceSection = optionalString syncCfg.enable
''
- BusID "${syncCfg.nvidiaBusId}"
+ BusID "${pCfg.nvidiaBusId}"
${optionalString syncCfg.allowExternalGpu "Option \"AllowExternalGpus\""}
'';
screenSection =
@@ -164,7 +165,7 @@ in
Section "Device"
Identifier "nvidia-optimus-intel"
Driver "modesetting"
- BusID "${syncCfg.intelBusId}"
+ BusID "${pCfg.intelBusId}"
Option "AccelMethod" "none"
EndSection
'';