2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-02-08 18:47:51 +00:00
|
|
|
|
|
|
|
let kernel = config.boot.kernelPackages; in
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2014-02-08 18:47:51 +00: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 10:32:47 +00:00
|
|
|
hardware.bumblebee.group = mkOption {
|
|
|
|
default = "wheel";
|
|
|
|
example = "video";
|
|
|
|
type = types.uniq types.str;
|
|
|
|
description = ''Group for bumblebee socket'';
|
|
|
|
};
|
2014-02-08 18:47:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.hardware.bumblebee.enable {
|
|
|
|
boot.blacklistedKernelModules = [ "nouveau" "nvidia" ];
|
|
|
|
boot.kernelModules = [ "bbswitch" ];
|
|
|
|
boot.extraModulePackages = [ kernel.bbswitch kernel.nvidia_x11 ];
|
|
|
|
|
2014-05-03 14:28:21 +00:00
|
|
|
environment.systemPackages = [ pkgs.bumblebee pkgs.primus ];
|
2014-02-08 18:47:51 +00:00
|
|
|
|
|
|
|
systemd.services.bumblebeed = {
|
|
|
|
description = "Bumblebee Hybrid Graphics Switcher";
|
|
|
|
wantedBy = [ "display-manager.service" ];
|
2014-05-02 10:32:47 +00:00
|
|
|
script = "bumblebeed --use-syslog -g ${config.hardware.bumblebee.group}";
|
2014-02-08 18:47:51 +00:00
|
|
|
path = [ kernel.bbswitch pkgs.bumblebee ];
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 60;
|
|
|
|
CPUSchedulingPolicy = "idle";
|
|
|
|
};
|
2014-05-02 10:32:47 +00:00
|
|
|
environment.LD_LIBRARY_PATH="/run/opengl-driver/lib/";
|
|
|
|
environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
|
2014-02-08 18:47:51 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|