1{ config, pkgs, lib, ... }:
2
3{
4
5 ###### interface
6
7 options = {
8
9 hardware.amdHybridGraphics.disable = lib.mkOption {
10 default = false;
11 type = lib.types.bool;
12 description = ''
13 Completely disable the AMD graphics card and use the
14 integrated graphics processor instead.
15 '';
16 };
17
18 };
19
20
21 ###### implementation
22
23 config = lib.mkIf config.hardware.amdHybridGraphics.disable {
24 systemd.services."amd-hybrid-graphics" = {
25 path = [ pkgs.bash ];
26 description = "Disable AMD Card";
27 after = [ "sys-kernel-debug.mount" ];
28 requires = [ "sys-kernel-debug.mount" ];
29 wantedBy = [ "multi-user.target" ];
30 serviceConfig = {
31 Type = "oneshot";
32 RemainAfterExit = true;
33 ExecStart = "${pkgs.bash}/bin/sh -c 'echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch; exit 0'";
34 ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch; exit 0'";
35 };
36 };
37 };
38
39}