nixos/bumblebee: update for new packages

This commit is contained in:
Nikolay Amiantov 2015-12-05 00:36:01 +03:00
parent 95629cf6f8
commit cf3202acac

View file

@ -2,10 +2,20 @@
with lib; with lib;
let let
cfg = config.hardware.bumblebee;
kernel = config.boot.kernelPackages; kernel = config.boot.kernelPackages;
bumblebee = if config.hardware.bumblebee.connectDisplay
then pkgs.bumblebee_display useNvidia = cfg.driver == "nvidia";
else pkgs.bumblebee;
bumblebee = pkgs.bumblebee.override {
inherit useNvidia;
useDisplayDevice = cfg.connectDisplay;
};
primus = pkgs.primus.override {
inherit useNvidia;
};
in in
@ -29,6 +39,7 @@ in
type = types.str; type = types.str;
description = ''Group for bumblebee socket''; description = ''Group for bumblebee socket'';
}; };
hardware.bumblebee.connectDisplay = mkOption { hardware.bumblebee.connectDisplay = mkOption {
default = false; default = false;
type = types.bool; type = types.bool;
@ -40,26 +51,30 @@ in
Only nvidia driver is supported so far. Only nvidia driver is supported so far.
''; '';
}; };
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 { config = mkIf config.hardware.bumblebee.enable {
boot.blacklistedKernelModules = [ "nouveau" "nvidia" ]; boot.blacklistedKernelModules = [ "nouveau" "nvidia" ];
boot.kernelModules = [ "bbswitch" ]; boot.kernelModules = [ "bbswitch" ];
boot.extraModulePackages = [ kernel.bbswitch kernel.nvidia_x11 ]; boot.extraModulePackages = [ kernel.bbswitch ] ++ optional useNvidia kernel.nvidia_x11;
environment.systemPackages = [ bumblebee pkgs.primus ]; environment.systemPackages = [ bumblebee primus ];
systemd.services.bumblebeed = { systemd.services.bumblebeed = {
description = "Bumblebee Hybrid Graphics Switcher"; description = "Bumblebee Hybrid Graphics Switcher";
wantedBy = [ "display-manager.service" ]; wantedBy = [ "display-manager.service" ];
path = [ kernel.bbswitch bumblebee ]; path = [ kernel.bbswitch bumblebee ];
serviceConfig = { serviceConfig = {
ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${config.hardware.bumblebee.group}"; ExecStart = "${bumblebee}/bin/bumblebeed --use-syslog -g ${cfg.group} --driver ${cfg.driver}";
Restart = "always";
RestartSec = 60;
CPUSchedulingPolicy = "idle";
}; };
environment.LD_LIBRARY_PATH="/run/opengl-driver/lib/";
environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/"; environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
}; };
}; };