Merge pull request #21227 from lheckemann/vgaswitcheroo

amd-hybrid-graphics: fix race condition

authored by

Joachim F and committed by
GitHub
0c40ea73 bb572f09

+11 -4
+11 -4
nixos/modules/services/hardware/amd-hybrid-graphics.nix
··· 25 25 path = [ pkgs.bash ]; 26 26 description = "Disable AMD Card"; 27 27 after = [ "sys-kernel-debug.mount" ]; 28 - requires = [ "sys-kernel-debug.mount" ]; 29 - wantedBy = [ "multi-user.target" ]; 28 + before = [ "systemd-vconsole-setup.service" "display-manager.service" ]; 29 + requires = [ "sys-kernel-debug.mount" "vgaswitcheroo.path" ]; 30 30 serviceConfig = { 31 31 Type = "oneshot"; 32 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'"; 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"; 35 41 }; 42 + wantedBy = ["multi-user.target"]; 36 43 }; 37 44 }; 38 45