mirror of
https://github.com/Ascyii/nixos.git
synced 2025-12-31 22:44:23 -05:00
43 lines
849 B
Nix
43 lines
849 B
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
inherit (lib) mkOption types;
|
|
|
|
singleBat = {
|
|
START_CHARGE_THRESH_BAT0 = 65;
|
|
STOP_CHARGE_THRESH_BAT0 = 85;
|
|
};
|
|
|
|
doubleBat = singleBat // {
|
|
START_CHARGE_THRESH_BAT1 = 65;
|
|
STOP_CHARGE_THRESH_BAT1 = 85;
|
|
};
|
|
|
|
in {
|
|
options.batMode = mkOption {
|
|
type = types.enum [ "single" "double" ];
|
|
default = "single";
|
|
};
|
|
|
|
config = {
|
|
powerManagement.powertop.enable = true;
|
|
|
|
services.upower = {
|
|
enable = true;
|
|
|
|
# In accordance with waybar battery colors
|
|
percentageLow = 30;
|
|
percentageCritical = 20;
|
|
percentageAction = 15;
|
|
|
|
criticalPowerAction = "PowerOff"; # This can destroy work
|
|
usePercentageForPolicy = true;
|
|
};
|
|
|
|
services.tlp = {
|
|
enable = true;
|
|
settings = if config.batMode == "single" then singleBat else doubleBat;
|
|
};
|
|
};
|
|
}
|