about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoachim F <joachifm@users.noreply.github.com>2017-04-28 12:47:00 +0100
committerGitHub <noreply@github.com>2017-04-28 12:47:00 +0100
commit0c40ea734033cc07ef5ff41ccc51d720b0650cea (patch)
tree281673172abcb518b083542bab32d4084e489486
parentbb572f0942685e89a73c1256cc9c3be6438524fe (diff)
parent689d8349aab7fb0d44ad459f27cd231b7b784ce1 (diff)
downloadnixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.tar
nixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.tar.gz
nixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.tar.bz2
nixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.tar.lz
nixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.tar.xz
nixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.tar.zst
nixlib-0c40ea734033cc07ef5ff41ccc51d720b0650cea.zip
Merge pull request #21227 from lheckemann/vgaswitcheroo
amd-hybrid-graphics: fix race condition
-rw-r--r--nixos/modules/services/hardware/amd-hybrid-graphics.nix15
1 files changed, 11 insertions, 4 deletions
diff --git a/nixos/modules/services/hardware/amd-hybrid-graphics.nix b/nixos/modules/services/hardware/amd-hybrid-graphics.nix
index 087bd0e04098..b0f9ff56d1b2 100644
--- a/nixos/modules/services/hardware/amd-hybrid-graphics.nix
+++ b/nixos/modules/services/hardware/amd-hybrid-graphics.nix
@@ -25,15 +25,22 @@
       path = [ pkgs.bash ];
       description = "Disable AMD Card";
       after = [ "sys-kernel-debug.mount" ];
-      requires = [ "sys-kernel-debug.mount" ];
-      wantedBy = [ "multi-user.target" ];
+      before = [ "systemd-vconsole-setup.service" "display-manager.service" ];
+      requires = [ "sys-kernel-debug.mount" "vgaswitcheroo.path" ];
       serviceConfig = {
         Type = "oneshot";
         RemainAfterExit = true;
-        ExecStart = "${pkgs.bash}/bin/sh -c 'echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch; exit 0'";
-        ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch; exit 0'";
+        ExecStart = "${pkgs.bash}/bin/sh -c 'echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch'";
+        ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'";
       };
     };
+    systemd.paths."vgaswitcheroo" = {
+      pathConfig = {
+        PathExists = "/sys/kernel/debug/vgaswitcheroo/switch";
+        Unit = "amd-hybrid-graphics.service";
+      };
+      wantedBy = ["multi-user.target"];
+    };
   };
 
 }