diff --git a/modules/system/hardware/power.nix b/modules/system/hardware/power.nix index a867c14..69a725b 100644 --- a/modules/system/hardware/power.nix +++ b/modules/system/hardware/power.nix @@ -33,73 +33,176 @@ in { enable = true; # sample config from https://github.com/NotAShelf/watt#sample-configuration settings = { - charger = { - # CPU governor to use - governor = "performance"; - # Turbo boost setting: "always", "auto", or "never" - turbo = "auto"; - - # Enable or disable automatic turbo management (when turbo = "auto") - enable_auto_turbo = true; - # Custom thresholds for auto turbo management - turbo_auto_settings = { - load_threshold_high = 70.0; - load_threshold_low = 30.0; - temp_threshold_high = 75.0; - initial_turbo_state = false; # whether turbo should be initially enabled (false = disabled) - }; - # Energy Performance Preference - epp = "performance"; - # Energy Performance Bias (0-15 scale or named value) - epb = "balance_performance"; - # Platform profile (if supported) - platform_profile = "performance"; - # Min/max frequency in MHz (optional) - min_freq_mhz = 800; - max_freq_mhz = 3500; - # Optional: Profile-specific battery charge thresholds (overrides global setting) - # battery_charge_thresholds = [40, 80] # Start at 40%, stop at 80% - }; - - battery = { - governor = "powersave"; - turbo = "auto"; - - # More conservative auto turbo settings on battery - enable_auto_turbo = true; - turbo_auto_settings = { - load_threshold_high = 80.0; - load_threshold_low = 40.0; - temp_threshold_high = 70.0; - # start with turbo disabled on battery for power savings - initial_turbo_state = false; - }; - epp = "power"; - epb = "balance_power"; - platform_profile = "low-power"; - - # Global battery charging thresholds (applied to both profiles unless overridden) - # Start charging at 40%, stop at 80% - extends battery lifespan - # take precedence over this global setting - battery_charge_thresholds = [40 90]; - min_freq_mhz = 800; - max_freq_mhz = 2500; - }; - - daemon = { - # Base polling interval in seconds - poll_interval_sec = 5; - # Enable adaptive polling that changes with system state - adaptive_interval = true; - # Minimum polling interval for adaptive polling (seconds) - min_poll_interval_sec = 1; - # Maximum polling interval for adaptive polling (seconds) - max_poll_interval_sec = 30; - # Double the polling interval when on battery to save power - throttle_on_battery = true; - # Logging level: Error, Warning, Info, Debug - log_level = "Info"; - }; + rule = [ + { + cpu = { + energy-performance-preference = "power"; + frequency-mhz-maximum = 2000; + governor = "powersave"; + turbo = false; + }; + "if" = { + is-more-than = 85; + value = "$cpu-temperature"; + }; + priority = 100; + } + { + cpu = { + energy-performance-preference = "power"; + frequency-mhz-maximum = 800; + governor = "powersave"; + turbo = false; + }; + "if" = { + all = [ + "?discharging" + { + is-less-than = 0.3; + value = "%power-supply-charge"; + } + ]; + }; + power = {platform-profile = "low-power";}; + priority = 90; + } + { + cpu = { + energy-performance-preference = "performance"; + governor = "performance"; + turbo = true; + }; + "if" = { + all = [ + { + is-more-than = 0.8; + value = "%cpu-usage"; + } + { + is-less-than = 30; + value = "$cpu-idle-seconds"; + } + { + is-less-than = 75; + value = "$cpu-temperature"; + } + ]; + }; + priority = 80; + } + { + cpu = { + energy-performance-bias = "balance_performance"; + energy-performance-preference = "performance"; + governor = "performance"; + turbo = true; + }; + "if" = { + all = [ + {not = "?discharging";} + { + is-more-than = 0.1; + value = "%cpu-usage"; + } + { + is-less-than = 80; + value = "$cpu-temperature"; + } + ]; + }; + priority = 70; + } + { + cpu = { + energy-performance-preference = "balance_performance"; + governor = "schedutil"; + }; + "if" = { + all = [ + { + is-more-than = 0.4; + value = "%cpu-usage"; + } + { + is-less-than = 0.8; + value = "%cpu-usage"; + } + ]; + }; + priority = 60; + } + { + cpu = { + energy-performance-preference = "power"; + governor = "powersave"; + turbo = false; + }; + "if" = { + all = [ + { + is-less-than = 0.2; + value = "%cpu-usage"; + } + { + is-more-than = 60; + value = "$cpu-idle-seconds"; + } + ]; + }; + priority = 50; + } + { + cpu = { + energy-performance-preference = "power"; + frequency-mhz-maximum = 1600; + governor = "powersave"; + turbo = false; + }; + "if" = { + is-more-than = 300; + value = "$cpu-idle-seconds"; + }; + priority = 40; + } + { + cpu = { + energy-performance-preference = "power"; + frequency-mhz-maximum = 2000; + governor = "powersave"; + turbo = false; + }; + "if" = { + all = [ + "?discharging" + { + is-less-than = 0.5; + value = "%power-supply-charge"; + } + ]; + }; + power = {platform-profile = "low-power";}; + priority = 30; + } + { + cpu = { + energy-performance-bias = "balance_power"; + energy-performance-preference = "power"; + frequency-mhz-maximum = 1800; + frequency-mhz-minimum = 200; + governor = "powersave"; + turbo = false; + }; + "if" = "?discharging"; + priority = 20; + } + { + cpu = { + energy-performance-preference = "balance_performance"; + governor = "schedutil"; + }; + priority = 0; + } + ]; }; }; services = {