summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorEdmund Wu <fangkazuto@gmail.com>2019-08-14 08:18:28 -0400
committerEdmund Wu <fangkazuto@gmail.com>2019-12-10 11:35:28 -0500
commite8daa1e35ca120c52f38fb08505f7f716073ead7 (patch)
tree72447deb43840d5089984e53abfe9795cfc8ebf4 /nixos
parentaca9ffe893bd7346c32b38c50eaee3022668c998 (diff)
downloadnixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.tar
nixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.tar.gz
nixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.tar.bz2
nixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.tar.lz
nixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.tar.xz
nixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.tar.zst
nixpkgs-e8daa1e35ca120c52f38fb08505f7f716073ead7.zip
nixos/nvidia: prime.sync.{intel,nvidia}BusId -> prime.{intel,nvidia}BusId
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/hardware/video/nvidia.nix57
1 files changed, 29 insertions, 28 deletions
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 (<option>hardware.nvidia.prime.sync.nvidiaBusId</option> and
-        <option>hardware.nvidia.prime.sync.intelBusId</option>).
+        specified (<option>hardware.nvidia.prime.nvidiaBusId</option> and
+        <option>hardware.nvidia.prime.intelBusId</option>).
 
         If you enable this, you may want to also enable kernel modesetting for the
         NVIDIA driver (<option>hardware.nvidia.modesetting.enable</option>) 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
       '';