1{ config, pkgs, lib, ... }:
2
3let kernel = config.boot.kernelPackages; in
4
5{
6
7 ###### interface
8
9 options = {
10
11 hardware.nvidiaOptimus.disable = lib.mkOption {
12 default = false;
13 type = lib.types.bool;
14 description = ''
15 Completely disable the NVIDIA graphics card and use the
16 integrated graphics processor instead.
17 '';
18 };
19
20 };
21
22
23 ###### implementation
24
25 config = lib.mkIf config.hardware.nvidiaOptimus.disable {
26 boot.blacklistedKernelModules = ["nouveau" "nvidia" "nvidiafb"];
27 boot.kernelModules = [ "bbswitch" ];
28 boot.extraModulePackages = [ kernel.bbswitch ];
29
30 systemd.services.bbswitch = {
31 description = "Disable NVIDIA Card";
32 wantedBy = [ "multi-user.target" ];
33 serviceConfig = {
34 Type = "oneshot";
35 RemainAfterExit = true;
36 ExecStart = "${kernel.bbswitch}/bin/discrete_vga_poweroff";
37 ExecStop = "${kernel.bbswitch}/bin/discrete_vga_poweron";
38 };
39 path = [ kernel.bbswitch ];
40 };
41 };
42
43}