Skip to content

Commit

Permalink
nixos/tlp: fixes to battery threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Oct 11, 2023
1 parent e4372a7 commit 031fea3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions hosts/sankyuu-nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ in
enable = true;
gpu = "amd";
};
laptop.tlp.batteryThreshold = {
start = 75;
stop = 80;
};
server.tailscale.enable = true;
};

Expand Down
16 changes: 8 additions & 8 deletions nixos/laptop/tlp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ in
};
batteryThreshold = {
start = lib.mkOption {
default = 0;
type = lib.types.int;
default = null;
example = 75;
type = with lib.types; nullOr int;
description = "Start of battery charging threshold";
};
stop = lib.mkOption {
default = 0;
type = lib.types.int;
default = null;
example = 80;
type = with lib.types; nullOr int;
description = "Stop of battery charging threshold";
};
};
Expand All @@ -44,10 +46,8 @@ in
CPU_SCALING_GOVERNOR_ON_AC = lib.mkIf (cfg.cpuFreqGovernor != null) cfg.cpuFreqGovernor;
CPU_SCALING_GOVERNOR_ON_BAT = lib.mkIf (cfg.cpuFreqGovernor != null) cfg.cpuFreqGovernor;
# Set battery thresholds
START_CHARGE_THRESH_BAT0 = cfg.batteryThreshold.start;
STOP_CHARGE_THRESH_BAT0 = cfg.batteryThreshold.stop;
# Use `tlp setcharge` to restore the charging thresholds
RESTORE_THRESHOLDS_ON_BAT = lib.mkDefault 1;
START_CHARGE_THRESH_BAT0 = lib.mkIf (cfg.batteryThreshold.start != null) cfg.batteryThreshold.start;
STOP_CHARGE_THRESH_BAT0 = lib.mkIf (cfg.batteryThreshold.stop != null) cfg.batteryThreshold.stop;
};
};
};
Expand Down

0 comments on commit 031fea3

Please sign in to comment.