2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-02-08 19:47:51 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2014-12-20 11:51:24 +01:00
|
|
|
let
|
2015-12-04 22:36:01 +01:00
|
|
|
cfg = config.hardware.bumblebee;
|
|
|
|
|
2014-12-20 11:51:24 +01:00
|
|
|
kernel = config.boot.kernelPackages;
|
2015-12-04 22:36:01 +01:00
|
|
|
|
|
|
|
useNvidia = cfg.driver == "nvidia";
|
|
|
|
|
|
|
|
bumblebee = pkgs.bumblebee.override {
|
|
|
|
inherit useNvidia;
|
|
|
|
useDisplayDevice = cfg.connectDisplay;
|
|
|
|
};
|
|
|
|
|
|
|
|
primus = pkgs.primus.override {
|
|
|
|
inherit useNvidia;
|
|
|
|
};
|
2014-12-20 11:51:24 +01:00
|
|
|
|
|
|
|
in
|
2014-02-08 19:47:51 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
2014-05-02 12:32:47 +02:00
|
|
|
hardware.bumblebee.group = mkOption {
|
|
|
|
default = "wheel";
|
|
|
|
example = "video";
|
2015-06-15 18:12:32 +02:00
|
|
|
type = types.str;
|
2014-05-02 12:32:47 +02:00
|
|
|
description = ''Group for bumblebee socket'';
|
|
|
|
};
|
2015-12-04 22:36:01 +01:00
|
|
|
|
2014-12-20 11:51:24 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
Only nvidia driver is supported so far.
|
|
|
|
'';
|
|
|
|
};
|
2015-12-04 22:36:01 +01:00
|
|
|
|
|
|
|
hardware.bumblebee.driver = mkOption {
|
|
|
|
default = "nvidia";
|
|
|
|
type = types.enum [ "nvidia" "nouveau" ];
|
|
|
|
description = ''
|
|
|
|
Set driver used by bumblebeed. Supported are nouveau and nvidia.
|
|
|
|
'';
|
|
|
|
};
|
2014-02-08 19:47:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.hardware.bumblebee.enable {
|
|
|
|
boot.blacklistedKernelModules = [ "nouveau" "nvidia" ];
|
|
|
|
boot.kernelModules = [ "bbswitch" ];
|
2015-12-04 22:36:01 +01:00
|
|
|
boot.extraModulePackages = [ kernel.bbswitch ] ++ optional useNvidia kernel.nvidia_x11;
|
2014-02-08 19:47:51 +01:00
|
|
|
|
2015-12-04 22:36:01 +01:00
|
|
|
environment.systemPackages = [ bumblebee primus ];
|
2014-02-08 19:47:51 +01:00
|
|
|
|
|
|
|
systemd.services.bumblebeed = {
|
|
|
|
description = "Bumblebee Hybrid Graphics Switcher";
|
|
|
|
wantedBy = [ "display-manager.service" ];
|
2014-12-20 11:51:24 +01:00
|
|
|
path = [ kernel.bbswitch bumblebee ];
|
2014-02-08 19:47:51 +01:00
|
|
|
serviceConfig = {
|
2015-12-04 22:36:01 +01:00
|
|
|
ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver}";
|
2014-02-08 19:47:51 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|