2018-07-20 21:56:59 +01:00
|
|
|
{ config, lib, ... }:
|
2012-02-06 19:14:42 +00:00
|
|
|
|
2013-08-26 11:18:26 +01:00
|
|
|
let kernel = config.boot.kernelPackages; in
|
2012-02-06 19:14:42 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
hardware.nvidiaOptimus.disable = lib.mkOption {
|
2012-02-06 19:14:42 +00:00
|
|
|
default = false;
|
2014-05-05 19:58:51 +01:00
|
|
|
type = lib.types.bool;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2013-08-26 11:18:26 +01:00
|
|
|
Completely disable the NVIDIA graphics card and use the
|
|
|
|
integrated graphics processor instead.
|
2012-02-06 19:14:42 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
config = lib.mkIf config.hardware.nvidiaOptimus.disable {
|
2018-01-29 12:46:15 +00:00
|
|
|
boot.blacklistedKernelModules = ["nouveau" "nvidia" "nvidiafb" "nvidia-drm"];
|
2012-02-06 19:14:42 +00:00
|
|
|
boot.kernelModules = [ "bbswitch" ];
|
|
|
|
boot.extraModulePackages = [ kernel.bbswitch ];
|
|
|
|
|
2013-08-24 10:38:32 +01:00
|
|
|
systemd.services.bbswitch = {
|
2013-08-26 11:18:26 +01:00
|
|
|
description = "Disable NVIDIA Card";
|
2013-08-24 10:38:32 +01: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 19:14:42 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|