at 16.09-beta 2.2 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4let 5 cfg = config.hardware.bumblebee; 6 7 kernel = config.boot.kernelPackages; 8 9 useNvidia = cfg.driver == "nvidia"; 10 11 bumblebee = pkgs.bumblebee.override { 12 inherit useNvidia; 13 useDisplayDevice = cfg.connectDisplay; 14 }; 15 16 primus = pkgs.primus.override { 17 inherit useNvidia; 18 }; 19 20in 21 22{ 23 24 options = { 25 hardware.bumblebee.enable = mkOption { 26 default = false; 27 type = types.bool; 28 description = '' 29 Enable the bumblebee daemon to manage Optimus hybrid video cards. 30 This should power off secondary GPU until its use is requested 31 by running an application with optirun. 32 33 Only nvidia driver is supported so far. 34 ''; 35 }; 36 hardware.bumblebee.group = mkOption { 37 default = "wheel"; 38 example = "video"; 39 type = types.str; 40 description = ''Group for bumblebee socket''; 41 }; 42 43 hardware.bumblebee.connectDisplay = mkOption { 44 default = false; 45 type = types.bool; 46 description = '' 47 Set to true if you intend to connect your discrete card to a 48 monitor. This option will set up your Nvidia card for EDID 49 discovery and to turn on the monitor signal. 50 51 Only nvidia driver is supported so far. 52 ''; 53 }; 54 55 hardware.bumblebee.driver = mkOption { 56 default = "nvidia"; 57 type = types.enum [ "nvidia" "nouveau" ]; 58 description = '' 59 Set driver used by bumblebeed. Supported are nouveau and nvidia. 60 ''; 61 }; 62 }; 63 64 config = mkIf config.hardware.bumblebee.enable { 65 boot.blacklistedKernelModules = [ "nouveau" "nvidia" ]; 66 boot.kernelModules = [ "bbswitch" ]; 67 boot.extraModulePackages = [ kernel.bbswitch ] ++ optional useNvidia kernel.nvidia_x11; 68 69 environment.systemPackages = [ bumblebee primus ]; 70 71 systemd.services.bumblebeed = { 72 description = "Bumblebee Hybrid Graphics Switcher"; 73 wantedBy = [ "display-manager.service" ]; 74 path = [ kernel.bbswitch bumblebee ]; 75 serviceConfig = { 76 ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver}"; 77 }; 78 }; 79 }; 80}