nixos-config/modules/power.nix

55 lines
1.8 KiB
Nix
Raw Normal View History

2019-08-27 23:41:02 +04:00
{ config, pkgs, lib, ... }:
with rec {
inherit (config) device deviceSpecific;
2019-08-27 23:41:02 +04:00
};
with deviceSpecific; {
services.tlp = {
2019-08-27 23:41:02 +04:00
enable = isLaptop;
2020-08-05 18:45:44 +04:00
# New settings format in master branch nixpkgs
# settings = {
# CPU_SCALING_GOVERNOR_ON_AC = "powersave";
# CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
# CPU_HWP_ON_AC = "balance_performance";
# CPU_HWP_ON_BAT = "balance_power";
# CPU_BOOST_ON_AC = 1;
# CPU_BOOST_ON_BAT = 0;
# SCHED_POWERSAVE_ON_AC = 0;
# SCHED_POWERSAVE_ON_BAT = 1;
# CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
# CPU_ENERGY_PERF_POLICY_ON_BAT = "balance_power";
# DISK_DEVICES = "\"nvme0n1 sda\"";
# DISK_APM_LEVEL_ON_AC = "\"255 254\"";
# DISK_APM_LEVEL_ON_BAT = "\"255 254\"";
# SATA_LINKPWR_ON_BAT = "\"med_power_with_dipm max_performance\"";
# SATA_LINKPWR_ON_AC = "\"med_power_with_dipm max_performance\"";
# };
extraConfig = ''
2019-09-17 23:07:22 +04:00
# Recommended
CPU_SCALING_GOVERNOR_ON_AC=powersave
CPU_SCALING_GOVERNOR_ON_BAT=powersave
CPU_HWP_ON_AC=balance_performance
CPU_HWP_ON_BAT=balance_power
CPU_BOOST_ON_AC=1
CPU_BOOST_ON_BAT=0
2020-02-12 02:35:54 +04:00
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
2020-03-31 17:04:07 +04:00
CPU_ENERGY_PERF_POLICY_ON_AC=balance_performance
CPU_ENERGY_PERF_POLICY_ON_BAT=balance_power
2020-02-12 02:35:54 +04:00
DISK_DEVICES="nvme0n1 sda"
2019-09-18 02:23:45 +04:00
DISK_APM_LEVEL_ON_AC="255 254"
2020-02-12 02:35:54 +04:00
DISK_APM_LEVEL_ON_BAT="255 254"
# To avoid filesystem corruption on btrfs formatted partitions
SATA_LINKPWR_ON_BAT="med_power_with_dipm max_performance"
SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance"
'';
2020-02-12 02:35:54 +04:00
2019-08-27 23:41:02 +04:00
};
2020-04-26 14:48:24 +04:00
2020-08-05 04:52:30 +04:00
services.undervolt = lib.mkIf (device == "Dell-Laptop") {
enable = true;
coreOffset = "-120";
gpuOffset = "-54";
2019-09-17 23:07:22 +04:00
};
2019-08-27 23:41:02 +04:00
}