diff options
Diffstat (limited to 'system/battery.nix')
-rw-r--r-- | system/battery.nix | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/system/battery.nix b/system/battery.nix new file mode 100644 index 0000000..42ee269 --- /dev/null +++ b/system/battery.nix @@ -0,0 +1,41 @@ +{ + lib, + config, + pkgs, + ... +}: let + inherit (lib) mkIf; +in { + config = mkIf config.battery { + # power monterting + services.upower = { + enable = !config.minimal; + percentageLow = 20; + percentageCritical = 10; + percentageAction = 4; + criticalPowerAction = "Hibernate"; + }; + + # power profiles + services.tlp = { + enable = !config.minimal; + settings = { + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 20; + }; + }; + + # packages + environment.systemPackages = with pkgs; [ + acpi + ]; + }; +} |