Hey all.
I used to get around 12 - 14 hours of battery life on idle with my old Debian 12 Stable install. With NixOS, on idle I get 9 hours, and in use I get 3 - 4.
I’ve followed a lot of the battery tweaks available on the forum, as well as online.
Including:
- Tweaking kernelparams.
- Using my device’s hardware on nixos-hardware (I couldn’t find the precision 5540, but found the 5530, and that’s been working).
- Using TLP & Auto-CPUFreq (I know it’s not recommended to use both at the same time, but that has given me better battery life than just using only one).
- Using ThermalD
- Enabling All Firmware
hardware.enableAllFirmware = true;
- Using the linux zen kernel.
- EnvyControl to use only integrated graphics.
Here’s my battery.nix file, I am importing this into configuration.nix and using nix flakes.
{ inputs, outputs, lib, config, pkgs, ... }:
{
## POWER
powerManagement = {
enable = true;
#cpuFreqGovernor = "schedutil";
};
services.power-profiles-daemon.enable = false;
services.auto-cpufreq.enable = true;
services.auto-cpufreq.settings = {
battery = {
governor = "powersave";
turbo = "never";
};
charger = {
governor = "performance";
turbo = "auto";
};
};
### KERNEL
boot.kernelParams = [
"ahci.mobile_lpm_policy=3"
"rtc_cmos.use_acpi_alarm=1"
];
### HWP
systemd.tmpfiles.rules = [
"w /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference - - - - balance_power"
];
### TLP
services.tlp = {
enable = true;
settings = {
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
PLATFORM_PROFILE_ON_AC = "performance";
PLATFORM_PROFILE_ON_BAT = "low-power";
CPU_BOOST_ON_AC=1;
CPU_BOOST_ON_BAT=0;
CPU_HWP_DYN_BOOST_ON_AC=1;
CPU_HWP_DYN_BOOST_ON_BAT=0;
#CPU_MIN_PERF_ON_AC = 0;
#CPU_MAX_PERF_ON_AC = 100;
#CPU_MIN_PERF_ON_BAT = 0;
#CPU_MAX_PERF_ON_BAT = 20;
#Optional helps save long term battery health
START_CHARGE_THRESH_BAT0 = 60; # 60 and below it starts to charge
STOP_CHARGE_THRESH_BAT0 = 90; # 90 and above it stops charging
};
};
### SYSTEM 76 SCHEDULER
services.system76-scheduler.settings.cfsProfiles.enable = true;
### POWERTOP
#powerManagement.powertop.enable = true;
### ThermalD
services.thermald.enable = true;
}
I am using:
Dell Precision 5540
NixOS-Unstable
91 Whr Battery
EnvyControl (sudo envycontrol -s integrated
, for running off only integrated graphics)
Neofetch:
▗▄▄▄ ▗▄▄▄▄ ▄▄▄▖ amon@nixos
▜███▙ ▜███▙ ▟███▛ ----------
▜███▙ ▜███▙▟███▛ OS: NixOS 24.05.20240306.9df3e30 (Uakari)
▜███▙ ▜██████▛ Host: Dell Inc. 0FMYX6
▟█████████████████▙ ▜████▛ ▟▙ Kernel: 6.7.7-zen1
▟███████████████████▙ ▜███▙ ▟██▙ Packages: 1721 (nix-system), 681 (nix-user), 8 (flatpak)
▄▄▄▄▖ ▜███▙ ▟███▛ Shell: zsh 5.9
▟███▛ ▜██▛ ▟███▛ Resolution: 1920x1080, 2560x1440
▟███▛ ▜▛ ▟███▛ WM: dwm
▟███████████▛ ▟██████████▙ Theme: WhiteSur-Dark [GTK2/3]
▜██████████▛ ▟███████████▛ Icons: WhiteSur-dark [GTK2/3]
▟███▛ ▟▙ ▟███▛ Terminal: kitty
▟███▛ ▟██▙ ▟███▛ Terminal Font: monospace 11.0
▟███▛ ▜███▙ ▝▀▀▀▀ CPU: Intel i9-9880H (16) @ 2.300GHz
▜██▛ ▜███▙ ▜██████████████████▛ GPU: NVIDIA Quadro T2000 Mobile / Max-Q
▜▛ ▟████▙ ▜████████████████▛ GPU: Intel CoffeeLake-H GT2 [UHD Graphics 630]
▟██████▙ ▜███▙ Memory: 2.77GiB / 31.00GiB
▟███▛▜███▙ ▜███▙ GPU Driver: Dell Device [1028:0906]
▟███▛ ▜███▙ ▜███▙
▝▀▀▀ ▀▀▀▀▘ ▀▀▀▘