mirror of
https://github.com/ItsDrike/nixdots
synced 2024-11-09 22:19:42 +00:00
Restructure & rework power management config
This commit is contained in:
parent
6545dda7f8
commit
08864662bb
23
system/roles/laptop/power/acpi.nix
Normal file
23
system/roles/laptop/power/acpi.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ pkgs, lib, config, ...}: let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
deviceType = config.myOptions.device.roles.type;
|
||||||
|
acceptedTypes = ["laptop"];
|
||||||
|
in {
|
||||||
|
config = mkIf (builtins.elem deviceType acceptedTypes) {
|
||||||
|
hardware.acpilight.enable = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [ acpi ];
|
||||||
|
|
||||||
|
# handle ACPI events
|
||||||
|
services.acpid.enable = true;
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
kernelModules = ["acpi_call"];
|
||||||
|
extraModulePackages = with config.boot.kernelPackages; [
|
||||||
|
acpi_call
|
||||||
|
cpupower
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
# This sets up power management using auto-cpufreq,
|
|
||||||
# alongside with upower and power-profiles-daemon.
|
|
||||||
# Together, this provides a complete alternative to TLP
|
|
||||||
{ pkgs, lib, config, ...}: let
|
|
||||||
inherit (lib) mkIf mkDefault;
|
|
||||||
deviceType = config.myOptions.device.roles.type;
|
|
||||||
acceptedTypes = ["laptop"];
|
|
||||||
in {
|
|
||||||
imports = [
|
|
||||||
./power-profiles-daemon
|
|
||||||
];
|
|
||||||
|
|
||||||
config = mkIf (builtins.elem deviceType acceptedTypes) {
|
|
||||||
services = {
|
|
||||||
# superior power management
|
|
||||||
auto-cpufreq = {
|
|
||||||
enable = true;
|
|
||||||
settings = let
|
|
||||||
MHz = x: x * 1000;
|
|
||||||
in {
|
|
||||||
battery = {
|
|
||||||
governor = "powersave";
|
|
||||||
scaling_min_freq = mkDefault (MHz 1200);
|
|
||||||
scaling_max_freq = mkDefault (MHz 1800);
|
|
||||||
turbo = "never";
|
|
||||||
};
|
|
||||||
|
|
||||||
charger = {
|
|
||||||
governor = "performance";
|
|
||||||
scaling_min_freq = mkDefault (MHz 1800);
|
|
||||||
scaling_max_freq = mkDefault (MHz 3800);
|
|
||||||
turbo = "auto";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# DBus service that provides power management support to applications
|
|
||||||
upower = {
|
|
||||||
enable = true;
|
|
||||||
percentageLow = 15;
|
|
||||||
percentageCritical = 5;
|
|
||||||
percentageAction = 3;
|
|
||||||
criticalPowerAction = "Hibernate";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,37 +1,15 @@
|
||||||
{ pkgs, lib, config, ...}: let
|
{ pkgs, lib, config, ...}: let
|
||||||
inherit (lib) mkIf mkDefault;
|
inherit (lib) mkIf;
|
||||||
deviceType = config.myOptions.device.roles.type;
|
deviceType = config.myOptions.device.roles.type;
|
||||||
acceptedTypes = ["laptop"];
|
acceptedTypes = ["laptop"];
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./auto-cpufreq
|
./power-profiles-daemon
|
||||||
|
./upower.nix
|
||||||
|
./acpi.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config = mkIf (builtins.elem deviceType acceptedTypes) {
|
config = mkIf (builtins.elem deviceType acceptedTypes) {
|
||||||
hardware.acpilight.enable = true;
|
environment.systemPackages = with pkgs; [ powertop ];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
acpi
|
|
||||||
powertop
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
|
||||||
# handle ACPI events
|
|
||||||
acpid.enable = true;
|
|
||||||
|
|
||||||
# temperature target on battery
|
|
||||||
undervolt = {
|
|
||||||
tempBat = 65; # deg C
|
|
||||||
package = pkgs.undervolt;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
boot = {
|
|
||||||
kernelModules = ["acpi_call"];
|
|
||||||
extraModulePackages = with config.boot.kernelPackages; [
|
|
||||||
acpi_call
|
|
||||||
cpupower
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
19
system/roles/laptop/power/upower.nix
Normal file
19
system/roles/laptop/power/upower.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{ pkgs, lib, config, ...}: let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
deviceType = config.myOptions.device.roles.type;
|
||||||
|
acceptedTypes = ["laptop"];
|
||||||
|
in {
|
||||||
|
config = mkIf (builtins.elem deviceType acceptedTypes) {
|
||||||
|
services = {
|
||||||
|
# DBus service that provides power management support to applications
|
||||||
|
upower = {
|
||||||
|
enable = true;
|
||||||
|
percentageLow = 15;
|
||||||
|
percentageCritical = 5;
|
||||||
|
percentageAction = 3;
|
||||||
|
criticalPowerAction = "Hibernate";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue