2014-05-05 20:58:51 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2013-11-08 18:13:08 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2014-05-05 20:58:51 +02:00
|
|
|
hardware.amdHybridGraphics.disable = lib.mkOption {
|
2013-11-08 18:13:08 +01:00
|
|
|
default = false;
|
2014-05-05 20:58:51 +02:00
|
|
|
type = lib.types.bool;
|
2013-11-08 18:13:08 +01:00
|
|
|
description = ''
|
|
|
|
Completely disable the AMD graphics card and use the
|
|
|
|
integrated graphics processor instead.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2014-05-05 20:58:51 +02:00
|
|
|
config = lib.mkIf config.hardware.amdHybridGraphics.disable {
|
2013-11-08 18:13:08 +01:00
|
|
|
systemd.services."amd-hybrid-graphics" = {
|
|
|
|
path = [ pkgs.bash ];
|
|
|
|
description = "Disable AMD Card";
|
|
|
|
after = [ "sys-kernel-debug.mount" ];
|
2016-12-17 11:36:56 +01:00
|
|
|
before = [ "systemd-vconsole-setup.service" "display-manager.service" ];
|
|
|
|
requires = [ "sys-kernel-debug.mount" "vgaswitcheroo.path" ];
|
2013-11-08 18:13:08 +01:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
2016-12-17 11:36:56 +01:00
|
|
|
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'";
|
2013-11-08 18:13:08 +01:00
|
|
|
};
|
|
|
|
};
|
2016-12-17 11:36:56 +01:00
|
|
|
systemd.paths."vgaswitcheroo" = {
|
|
|
|
pathConfig = {
|
|
|
|
PathExists = "/sys/kernel/debug/vgaswitcheroo/switch";
|
|
|
|
Unit = "amd-hybrid-graphics.service";
|
|
|
|
};
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
};
|
2013-11-08 18:13:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|