dotfiles/nixos/hosts/utol/power-saving.nix
2024-11-07 16:25:41 -07:00

50 lines
1.5 KiB
Nix

#
# Power Saving configuration for utol.
# FIXME: module this
#
{ pkgs, deprekages, ... }:
let
ppdConfig = pkgs.writeText "ryzen-ppd.conf" ''
[ryzenadj]
limits = ["stapm_limit", "fast_limit", "slow_limit", "apu_slow_limit", "tctl_temp", "apu_skin_temp_limit"]
monitor = stapm_limit
# Profiles contain power and thermal limits in the same order as the limit names defined in the
# [ryzenadj] section. The following table shows settings recorded in Windows while moving the power
# slider and running 'ryzenadj -i'. On Linux the balanced profile was the default. Additionally a
# custom profile with slightly increased limits is included.
# Format: JSON array of integers. Defaults: None
[profiles]
battery = [ 11000, 8800, 8800, 12000, 70, 45 ]
low-power = [ 11000, 9900, 9900, 13500, 70, 45 ]
balanced = [ 20000, 20000, 15000, 15000, 86, 45 ]
performance = [ 30000, 30000, 28000, 17000, 96, 64 ]
[ac]
profile = performance
update_rate_s = 4
[battery]
profile = low-power
update_rate_s = 32 '';
in
{
# Set up upower to notify ryzen-ppd...
services.upower.enable = true;
# ... and ryzen-ppd itself to run our configruation.
systemd.services.ryzen-ppd = {
description = "ryzen power management configuration";
wantedBy = [ "default.target" ];
# Run rclone mount.
serviceConfig = {
Type = "simple";
ExecStart = "${deprekages.ryzen-ppd}/bin/ryzen-ppd -c ${ppdConfig}";
Restart = "on-failure";
};
};
}