Powersave: Move tlp to laptop powersave.

This commit is contained in:
Dmitry Voronin 2025-01-12 08:56:20 +03:00
parent 68e104dd73
commit 57b5606e27
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
3 changed files with 42 additions and 23 deletions

View file

@ -34,28 +34,34 @@ let
'';
in
{
config = lib.mkIf cfg.enable {
services = {
tlp.enable = true;
upower.enable = true;
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
environment.systemPackages = [ script ];
systemd = {
services.powersave-cpu = {
enable = true;
description = "disable CPU Boost";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
RemainAfterExit = "yes";
ExecStart = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.enableCmd} > ${cfg.cpu.boost.controlFile}'";
ExecStop = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.disableCmd} > ${cfg.cpu.boost.controlFile}'";
};
};
environment.systemPackages = [ script ];
systemd = {
services.powersave-cpu = {
enable = true;
description = "disable CPU Boost";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
RemainAfterExit = "yes";
ExecStart = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.enableCmd} > ${cfg.cpu.boost.controlFile}'";
ExecStop = "${lib.getExe pkgs.bash} -c 'echo ${cfg.cpu.boost.disableCmd} > ${cfg.cpu.boost.controlFile}'";
# HACK: Allow user access.
tmpfiles.rules = [ "z ${cfg.cpu.boost.controlFile} 0777 - - - -" ];
};
};
}
# HACK: Allow user access.
tmpfiles.rules = [ "z ${cfg.cpu.boost.controlFile} 0777 - - - -" ];
};
};
(lib.mkIf cfg.laptop {
services = {
tlp.enable = true;
upower.enable = true;
};
})
]
);
}

View file

@ -1,4 +1,10 @@
{ __findFile, config, lib, pkgs, ... }:
{
__findFile,
config,
lib,
pkgs,
...
}:
{
enable = true;
package = pkgs.thunderbird-esr;

View file

@ -1,7 +1,14 @@
{ lib, ... }:
{ lib, config, ... }:
let
purpose = config.module.purpose;
in
{
options.module.powersave = {
enable = lib.mkEnableOption "the powersave";
laptop = lib.mkOption {
default = purpose.laptop;
type = lib.types.bool;
};
cpu.boost = {
disableCmd = lib.mkOption {
default = null;