gihcomit
This commit is contained in:
51
config/modules/power-management/tdp.nix
Normal file
51
config/modules/power-management/tdp.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{ modules, den, ... }:
|
||||
{
|
||||
modules.tdp = settings: {
|
||||
nixos =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
batt-tdp = pkgs.writeShellScript "batt-cpu-tdp" ''
|
||||
${pkgs.powercap}/bin/powercap-set intel-rapl -z 0 -c 0 -l ${
|
||||
toString (settings.batt.cpu.long-term * 1000000)
|
||||
}
|
||||
${pkgs.powercap}/bin/powercap-set intel-rapl -z 0 -c 0 -l ${
|
||||
toString (settings.batt.cpu.short-term * 1000000)
|
||||
}
|
||||
'';
|
||||
ac-tdp = pkgs.writeShellScript "ac-cpu-tdp" ''
|
||||
${pkgs.powercap}/bin/powercap-set intel-rapl -z 0 -c 0 -l ${
|
||||
toString (settings.ac.cpu.long-term * 1000000)
|
||||
}
|
||||
${pkgs.powercap}/bin/powercap-set intel-rapl -z 0 -c 0 -l ${
|
||||
toString (settings.ac.cpu.short-term * 1000000)
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
systemd.services.tdp-on-batt = {
|
||||
enable = true;
|
||||
before = [ "battery.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${batt-tdp}";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
wantedBy = [ "battery.target" ];
|
||||
partOf = [ "battery.target" ];
|
||||
};
|
||||
systemd.services.tdp-on-ac = {
|
||||
enable = true;
|
||||
before = [ "ac.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${ac-tdp}";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
wantedBy = [ "ac.target" ];
|
||||
partOf = [ "ac.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user