2013-08-26 12:18:26 +02:00
|
|
|
{ config, pkgs, ... }:
|
2012-02-06 20:14:42 +01:00
|
|
|
|
2013-08-26 12:18:26 +02:00
|
|
|
let kernel = config.boot.kernelPackages; in
|
2012-02-06 20:14:42 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
hardware.nvidiaOptimus.disable = pkgs.lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = pkgs.lib.types.bool;
|
|
|
|
description = ''
|
2013-08-26 12:18:26 +02:00
|
|
|
Completely disable the NVIDIA graphics card and use the
|
|
|
|
integrated graphics processor instead.
|
2012-02-06 20:14:42 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = pkgs.lib.mkIf config.hardware.nvidiaOptimus.disable {
|
|
|
|
boot.blacklistedKernelModules = ["nouveau" "nvidia" "nvidiafb"];
|
|
|
|
boot.kernelModules = [ "bbswitch" ];
|
|
|
|
boot.extraModulePackages = [ kernel.bbswitch ];
|
|
|
|
|
2013-08-24 11:38:32 +02:00
|
|
|
systemd.services.bbswitch = {
|
2013-08-26 12:18:26 +02:00
|
|
|
description = "Disable NVIDIA Card";
|
2013-08-24 11:38:32 +02:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
ExecStart = "${kernel.bbswitch}/bin/discrete_vga_poweroff";
|
|
|
|
ExecStop = "${kernel.bbswitch}/bin/discrete_vga_poweron";
|
|
|
|
};
|
|
|
|
path = [ kernel.bbswitch ];
|
2012-02-06 20:14:42 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|