summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-11-21 17:16:35 +0300
committerNikolay Amiantov <ab@fmap.me>2016-11-21 17:29:31 +0300
commitf10ec922e06c99a89a65bfcbff8e2c5a399ee5bf (patch)
treeadf91652bca96b6cf3a478a2fc91ea89ead2682e
parent44808cac65a8b323549fdbf3f1ca35c0bf746fe8 (diff)
downloadnixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.tar
nixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.tar.gz
nixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.tar.bz2
nixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.tar.lz
nixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.tar.xz
nixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.tar.zst
nixpkgs-f10ec922e06c99a89a65bfcbff8e2c5a399ee5bf.zip
bumblebee service: make bbswitch optional
-rw-r--r--nixos/modules/hardware/video/bumblebee.nix84
1 files changed, 48 insertions, 36 deletions
diff --git a/nixos/modules/hardware/video/bumblebee.nix b/nixos/modules/hardware/video/bumblebee.nix
index 8b40e22d676..34571b344e5 100644
--- a/nixos/modules/hardware/video/bumblebee.nix
+++ b/nixos/modules/hardware/video/bumblebee.nix
@@ -22,49 +22,61 @@ in
 {
 
   options = {
-    hardware.bumblebee.enable = mkOption {
-      default = false;
-      type = types.bool;
-      description = ''
-        Enable the bumblebee daemon to manage Optimus hybrid video cards.
-        This should power off secondary GPU until its use is requested
-        by running an application with optirun.
-
-        Only nvidia driver is supported so far.
-      '';
-    };
-    hardware.bumblebee.group = mkOption {
-      default = "wheel";
-      example = "video";
-      type = types.str;
-      description = ''Group for bumblebee socket'';
-    };
+    hardware.bumblebee = {
+
+      enable = mkOption {
+        default = false;
+        type = types.bool;
+        description = ''
+          Enable the bumblebee daemon to manage Optimus hybrid video cards.
+          This should power off secondary GPU until its use is requested
+          by running an application with optirun.
+        '';
+      };
 
-    hardware.bumblebee.connectDisplay = mkOption {
-      default = false;
-      type = types.bool;
-      description = ''
-        Set to true if you intend to connect your discrete card to a
-        monitor. This option will set up your Nvidia card for EDID
-        discovery and to turn on the monitor signal.
+      group = mkOption {
+        default = "wheel";
+        example = "video";
+        type = types.str;
+        description = ''Group for bumblebee socket'';
+      };
 
-        Only nvidia driver is supported so far.
-      '';
-    };
+      connectDisplay = mkOption {
+        default = false;
+        type = types.bool;
+        description = ''
+          Set to true if you intend to connect your discrete card to a
+          monitor. This option will set up your Nvidia card for EDID
+          discovery and to turn on the monitor signal.
+
+          Only nvidia driver is supported so far.
+        '';
+      };
+
+      driver = mkOption {
+        default = "nvidia";
+        type = types.enum [ "nvidia" "nouveau" ];
+        description = ''
+          Set driver used by bumblebeed. Supported are nouveau and nvidia.
+        '';
+      };
+
+      bbswitch = mkOption {
+        default = true;
+        type = types.bool;
+        description = ''
+          Set to true if you want to use bbswitch for power management of
+          unused card.
+        '';
+      };
 
-    hardware.bumblebee.driver = mkOption {
-      default = "nvidia";
-      type = types.enum [ "nvidia" "nouveau" ];
-      description = ''
-        Set driver used by bumblebeed. Supported are nouveau and nvidia.
-      '';
     };
   };
 
-  config = mkIf config.hardware.bumblebee.enable {
+  config = mkIf cfg.enable {
     boot.blacklistedKernelModules = [ "nvidia-drm" "nvidia" "nouveau" ];
-    boot.kernelModules = [ "bbswitch" ];
-    boot.extraModulePackages = [ kernel.bbswitch ] ++ optional useNvidia kernel.nvidia_x11;
+    boot.kernelModules = optional cfg.bbswitch [ "bbswitch" ];
+    boot.extraModulePackages = optional cfg.bbswitch kernel.bbswitch ++ optional useNvidia kernel.nvidia_x11;
 
     environment.systemPackages = [ bumblebee primus ];