1 { config, lib, pkgs, ... }:
3 cfg = config.hardware.bumblebee;
5 kernel = config.boot.kernelPackages;
7 useNvidia = cfg.driver == "nvidia";
9 bumblebee = pkgs.bumblebee.override {
11 useDisplayDevice = cfg.connectDisplay;
14 useBbswitch = cfg.pmMethod == "bbswitch" || cfg.pmMethod == "auto" && useNvidia;
16 primus = pkgs.primus.override {
25 hardware.bumblebee = {
27 enable = lib.mkOption {
29 type = lib.types.bool;
31 Enable the bumblebee daemon to manage Optimus hybrid video cards.
32 This should power off secondary GPU until its use is requested
33 by running an application with optirun.
37 group = lib.mkOption {
41 description = "Group for bumblebee socket";
44 connectDisplay = lib.mkOption {
46 type = lib.types.bool;
48 Set to true if you intend to connect your discrete card to a
49 monitor. This option will set up your Nvidia card for EDID
50 discovery and to turn on the monitor signal.
52 Only nvidia driver is supported so far.
56 driver = lib.mkOption {
58 type = lib.types.enum [ "nvidia" "nouveau" ];
60 Set driver used by bumblebeed. Supported are nouveau and nvidia.
64 pmMethod = lib.mkOption {
66 type = lib.types.enum [ "auto" "bbswitch" "switcheroo" "none" ];
68 Set preferred power management method for unused card.
75 config = lib.mkIf cfg.enable {
76 boot.blacklistedKernelModules = [ "nvidia-drm" "nvidia" "nouveau" ];
77 boot.kernelModules = lib.optional useBbswitch "bbswitch";
78 boot.extraModulePackages = lib.optional useBbswitch kernel.bbswitch ++ lib.optional useNvidia kernel.nvidia_x11.bin;
80 environment.systemPackages = [ bumblebee primus ];
82 systemd.services.bumblebeed = {
83 description = "Bumblebee Hybrid Graphics Switcher";
84 wantedBy = [ "multi-user.target" ];
85 before = [ "display-manager.service" ];
87 ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver} --pm-method ${cfg.pmMethod}";