diff options
Diffstat (limited to 'nixos/modules/hardware/video/bumblebee.nix')
-rw-r--r-- | nixos/modules/hardware/video/bumblebee.nix | 93 |
1 files changed, 53 insertions, 40 deletions
diff --git a/nixos/modules/hardware/video/bumblebee.nix b/nixos/modules/hardware/video/bumblebee.nix index 69db518ab21c..3ce97ad31c22 100644 --- a/nixos/modules/hardware/video/bumblebee.nix +++ b/nixos/modules/hardware/video/bumblebee.nix @@ -13,6 +13,8 @@ let useDisplayDevice = cfg.connectDisplay; }; + useBbswitch = cfg.pmMethod == "bbswitch"; + primus = pkgs.primus.override { inherit useNvidia; }; @@ -22,58 +24,69 @@ 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 = { - 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. + 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. - ''; - }; + group = mkOption { + default = "wheel"; + example = "video"; + type = types.str; + description = ''Group for bumblebee socket''; + }; + + 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. + ''; + }; + + pmMethod = mkOption { + default = "auto"; + type = types.enum [ "auto" "bbswitch" "nouveau" "switcheroo" "none" ]; + description = '' + Set preferred power management method for 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 { - boot.blacklistedKernelModules = [ "nouveau" "nvidia" ]; - boot.kernelModules = [ "bbswitch" ]; - boot.extraModulePackages = [ kernel.bbswitch ] ++ optional useNvidia kernel.nvidia_x11; + config = mkIf cfg.enable { + boot.blacklistedKernelModules = [ "nvidia-drm" "nvidia" "nouveau" ]; + boot.kernelModules = optional useBbswitch [ "bbswitch" ]; + boot.extraModulePackages = optional useBbswitch kernel.bbswitch ++ optional useNvidia kernel.nvidia_x11; environment.systemPackages = [ bumblebee primus ]; systemd.services.bumblebeed = { description = "Bumblebee Hybrid Graphics Switcher"; - wantedBy = [ "display-manager.service" ]; - path = [ kernel.bbswitch bumblebee ]; + wantedBy = [ "multi-user.target" ]; + before = [ "display-manager.service" ]; serviceConfig = { - ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver}"; + ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver} --pm-method ${cfg.pmMethod}"; }; }; }; |