mirror of
https://github.com/Unkn0wnCat/dotfiles.git
synced 2025-04-29 01:46:19 +02:00
78 lines
2.5 KiB
Nix
78 lines
2.5 KiB
Nix
{ lib, pkgs, config, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.kevin.power;
|
|
in {
|
|
options.kevin.power = {
|
|
mode = mkOption {
|
|
type = types.enum [ "desktop" "laptop" ];
|
|
default = "desktop";
|
|
};
|
|
};
|
|
|
|
config = mkMerge [
|
|
(mkIf (cfg.mode == "laptop") {
|
|
powerManagement.powertop.enable = true;
|
|
services.thermald.enable = true;
|
|
services.power-profiles-daemon.enable = false;
|
|
|
|
services.tlp = {
|
|
enable = true;
|
|
settings = {
|
|
START_CHARGE_THRESH_BAT0 = 85;
|
|
STOP_CHARGE_THRESH_BAT0 = 90;
|
|
|
|
CPU_SCALING_GOVERNOR_ON_AC = "schedutil";
|
|
CPU_SCALING_GOVERNOR_ON_BAT = "schedutil";
|
|
|
|
CPU_SCALING_MIN_FREQ_ON_AC = 800000;
|
|
CPU_SCALING_MAX_FREQ_ON_AC = 2201000;
|
|
CPU_SCALING_MIN_FREQ_ON_BAT = 400000;
|
|
CPU_SCALING_MAX_FREQ_ON_BAT = 2100000;
|
|
|
|
# Enable audio power saving for Intel HDA, AC97 devices (timeout in secs).
|
|
# A value of 0 disables, >=1 enables power saving (recommended: 1).
|
|
# Default: 0 (AC), 1 (BAT)
|
|
SOUND_POWER_SAVE_ON_AC = 0;
|
|
SOUND_POWER_SAVE_ON_BAT = 1;
|
|
|
|
# Runtime Power Management for PCI(e) bus devices: on=disable, auto=enable.
|
|
# Default: on (AC), auto (BAT)
|
|
RUNTIME_PM_ON_AC = "on";
|
|
RUNTIME_PM_ON_BAT = "auto";
|
|
|
|
# Battery feature drivers: 0=disable, 1=enable
|
|
# Default: 1 (all)
|
|
NATACPI_ENABLE = 1;
|
|
TPACPI_ENABLE = 1;
|
|
TPSMAPI_ENABLE = 1;
|
|
};
|
|
|
|
};
|
|
|
|
boot.extraModprobeConfig = lib.mkMerge [
|
|
# idle audio card after one second
|
|
"options snd_hda_intel power_save=1"
|
|
# enable wifi power saving (keep uapsd off to maintain low latencies)
|
|
"options iwlwifi power_save=1 uapsd_disable=1"
|
|
];
|
|
|
|
boot.initrd.availableKernelModules = [
|
|
"thinkpad_acpi"
|
|
];
|
|
|
|
boot.kernelParams = ["intel_pstate=disable"];
|
|
boot.kernelModules = ["acpi_call" "coretemp" "cpuid"];
|
|
|
|
services.udev.extraRules = lib.mkMerge [
|
|
# autosuspend USB devices
|
|
''ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"''
|
|
# autosuspend PCI devices
|
|
''ACTION=="add", SUBSYSTEM=="pci", TEST=="power/control", ATTR{power/control}="auto"''
|
|
# disable Ethernet Wake-on-LAN
|
|
''ACTION=="add", SUBSYSTEM=="net", NAME=="enp*", RUN+="${pkgs.ethtool}/sbin/ethtool -s $name wol d"''
|
|
];
|
|
services.upower.enable = true;
|
|
})
|
|
];
|
|
}
|