From 9a9d0ba266f3d78f8edf816d4944d5ec8bd450b0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 13 May 2021 15:05:57 +0200 Subject: [PATCH] services: add TLP --- services/default.nix | 1 + services/tlp.nix | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 services/tlp.nix diff --git a/services/default.nix b/services/default.nix index fc377d9..6096454 100644 --- a/services/default.nix +++ b/services/default.nix @@ -22,6 +22,7 @@ ./rss-bridge.nix ./sabnzbd.nix ./ssh-server.nix + ./tlp.nix ./transmission.nix ./wireguard.nix ]; diff --git a/services/tlp.nix b/services/tlp.nix new file mode 100644 index 0000000..a560319 --- /dev/null +++ b/services/tlp.nix @@ -0,0 +1,22 @@ +# TLP power management +{ config, lib, ... }: +let + cfg = config.my.services.tlp; +in +{ + options.my.services.tlp = { + enable = lib.mkEnableOption "TLP power management configuration"; + }; + + config = lib.mkIf cfg.enable { + services.tlp = { + enable = true; + + settings = { + # Keep charge between 60% and 80% to preserve battery life + START_CHARGE_THRESH_BAT0 = 60; + STOP_CHARGE_THRESH_BAT0 = 80; + }; + }; + }; +}