about summary refs log tree commit diff
path: root/nixos/modules/hardware
diff options
context:
space:
mode:
authorEdmund Wu <fangkazuto@gmail.com>2019-08-14 12:37:03 -0400
committerEdmund Wu <fangkazuto@gmail.com>2019-12-10 11:35:29 -0500
commit632a8a7bb27b5e852becf0c4cd451cde18237f1b (patch)
tree84a107a0cd203f9996d0be38760c9813e4e75344 /nixos/modules/hardware
parente8daa1e35ca120c52f38fb08505f7f716073ead7 (diff)
downloadnixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.tar
nixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.tar.gz
nixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.tar.bz2
nixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.tar.lz
nixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.tar.xz
nixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.tar.zst
nixlib-632a8a7bb27b5e852becf0c4cd451cde18237f1b.zip
nixos/xserver: introduce attr display to xserver.drivers
Specifically for NVIDIA so that only the device section would be created
Diffstat (limited to 'nixos/modules/hardware')
-rw-r--r--nixos/modules/hardware/video/amdgpu-pro.nix2
-rw-r--r--nixos/modules/hardware/video/ati.nix2
-rw-r--r--nixos/modules/hardware/video/nvidia.nix29
3 files changed, 15 insertions, 18 deletions
diff --git a/nixos/modules/hardware/video/amdgpu-pro.nix b/nixos/modules/hardware/video/amdgpu-pro.nix
index 8e91e9d2baa9..ec1c8c2d57a1 100644
--- a/nixos/modules/hardware/video/amdgpu-pro.nix
+++ b/nixos/modules/hardware/video/amdgpu-pro.nix
@@ -30,7 +30,7 @@ in
     nixpkgs.config.xorg.abiCompat = "1.19";
 
     services.xserver.drivers = singleton
-      { name = "amdgpu"; modules = [ package ]; };
+      { name = "amdgpu"; modules = [ package ]; display = true; };
 
     hardware.opengl.package = package;
     hardware.opengl.package32 = package32;
diff --git a/nixos/modules/hardware/video/ati.nix b/nixos/modules/hardware/video/ati.nix
index 0aab7bd6b92c..06d3ea324d8d 100644
--- a/nixos/modules/hardware/video/ati.nix
+++ b/nixos/modules/hardware/video/ati.nix
@@ -21,7 +21,7 @@ in
     nixpkgs.config.xorg.abiCompat = "1.17";
 
     services.xserver.drivers = singleton
-      { name = "fglrx"; modules = [ ati_x11 ]; };
+      { name = "fglrx"; modules = [ ati_x11 ]; display = true; };
 
     hardware.opengl.package = ati_x11;
     hardware.opengl.package32 = pkgs.pkgsi686Linux.linuxPackages.ati_drivers_x11.override { libsOnly = true; kernel = null; };
diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix
index 295180d2b64e..e3ef0e7a846b 100644
--- a/nixos/modules/hardware/video/nvidia.nix
+++ b/nixos/modules/hardware/video/nvidia.nix
@@ -125,8 +125,7 @@ in
       }
 
       {
-        assertion = !syncCfg.enable ||
-          (pCfg.nvidiaBusId != "" && pCfg.intelBusId != "");
+        assertion = syncCfg.enable -> pCfg.nvidiaBusId != "" && pCfg.intelBusId != "";
         message = ''
           When NVIDIA Optimus via PRIME is enabled, the GPU bus IDs must configured.
         '';
@@ -145,9 +144,17 @@ in
     # - Configure the display manager to run specific `xrandr` commands which will
     #   configure/enable displays connected to the Intel GPU.
 
-    services.xserver.drivers = singleton {
+    services.xserver.drivers = optional syncCfg.enable {
+      name = "modesetting";
+      display = false;
+      deviceSection = ''
+        BusID "${pCfg.intelBusId}"
+        Option "AccelMethod" "none"
+      '';
+    } ++ singleton {
       name = "nvidia";
       modules = [ nvidia_x11.bin ];
+      display = true;
       deviceSection = optionalString syncCfg.enable
         ''
           BusID "${pCfg.nvidiaBusId}"
@@ -160,19 +167,9 @@ in
         '';
     };
 
-    services.xserver.extraConfig = optionalString syncCfg.enable
-      ''
-        Section "Device"
-          Identifier "nvidia-optimus-intel"
-          Driver "modesetting"
-          BusID  "${pCfg.intelBusId}"
-          Option "AccelMethod" "none"
-        EndSection
-      '';
-    services.xserver.serverLayoutSection = optionalString syncCfg.enable
-      ''
-        Inactive "nvidia-optimus-intel"
-      '';
+    services.xserver.serverLayoutSection = optionalString syncCfg.enable ''
+      Inactive "Device-modesetting[0]"
+    '';
 
     services.xserver.displayManager.setupCommands = optionalString syncCfg.enable ''
       # Added by nvidia configuration module for Optimus/PRIME.