Files
dotfiles/hosts/doloro-laptop/laptop.nix
2026-01-06 16:14:04 +00:00

97 lines
2.7 KiB
Nix

{ pkgs, lib, ... }:
let
in
{
services.power-profiles-daemon.enable = true;
services.tlp = {
enable = true;
settings = {
CPU_ENERGY_PERF_POLICY_ON_BAT = "powersave";
# Wireless power saving
WIFI_PWR_ON_BAT = "1";
# USB autosuspend
USB_AUTOSUSPEND = "1";
# SATA drive power management
SATA_LINKPWR_ON_BAT = "min_power";
# PCI Express Active-State Power Management (ASPM)
PCIE_ASPM_ON_BAT = "powersave";
# Runtime Power Management for PCI(e) buses/devices
RUNTIME_PM_ON_BAT = "auto";
# Disable Bluetooth on battery
# DEVICES_TO_DISABLE_ON_BAT = "bluetooth";
# Restore brightness on battery
RESTORE_BRIGHTNESS_ON_BAT = "1";
CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
# CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_ENERGY_PERF_POLICY_ON_SAV = "power";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
# PCIE_ASPM_ON_BAT = "powersave";
CPU_SCALING_GOVERNOR_ON_AC = "balanced";
PCIE_ASPM_ON_AC = "balanced";
CPU_BOOST_ON_AC = 1;
CPU_BOOST_ON_BAT = 0;
CPU_BOOST_ON_SAV = 0;
DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE = "bluetooth wifi wwan";
TLP_DEFAULT_BATTERY_MODE = "SAV";
CPU_HWP_DYN_BOOST_ON_AC = 1;
CPU_HWP_DYN_BOOST_ON_BAT = 0;
CPU_HWP_DYN_BOOST_ON_SAV = 0;
PLATFORM_PROFILE_ON_AC = "balanced";
PLATFORM_PROFILE_ON_BAT = "low-power";
PLATFORM_PROFILE_ON_SAV = "quiet";
START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge
STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging
};
};
# services.tuned.enable = true;
services.thermald.enable = true;
services.upower = {
enable = true;
};
boot.kernelParams = [
# "mem_sleep_default=deep"
"i915.fastboot=1"
"pcie_aspm=force"
"ahci.mobile_lpm_policy=1"
];
services.logind.settings.Login = {
HandleLidSwitch = "suspend";
HandleLidSwitchExternalPower = "suspend";
HandleLidSwitchDocked = "ignore";
};
systemd.sleep.extraConfig = ''
HibernateDelaySec=30min
SuspendEstimationSec=120
'';
systemd.services.rfkill-sleep-wake = {
enable = true;
description = "Using rfkill; disable all rf devices before sleeping.";
before = [ "sleep.target" ];
serviceConfig = {
Type = "oneshot";
ExecStop = ''${pkgs.utillinux}/bin/rfkill unblock all'';
ExecStart = ''${pkgs.utillinux}/bin/rfkill block all'';
RemainAfterExit = true;
};
wantedBy = [ "sleep.target" ];
partOf = [ "sleep.target" ];
};
# one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", "lock"
powerManagement = {
enable = true;
# powertop.enable = true;
};
}