at 17.09-beta 1.3 kB view raw
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 before = [ "systemd-vconsole-setup.service" "display-manager.service" ]; 29 requires = [ "sys-kernel-debug.mount" "vgaswitcheroo.path" ]; 30 serviceConfig = { 31 Type = "oneshot"; 32 RemainAfterExit = true; 33 ExecStart = "${pkgs.bash}/bin/sh -c 'echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch'"; 34 ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'"; 35 }; 36 }; 37 systemd.paths."vgaswitcheroo" = { 38 pathConfig = { 39 PathExists = "/sys/kernel/debug/vgaswitcheroo/switch"; 40 Unit = "amd-hybrid-graphics.service"; 41 }; 42 wantedBy = ["multi-user.target"]; 43 }; 44 }; 45 46}