nixos/tlp: add pd options

This commit is contained in:
aleksana
2026-01-01 20:55:57 +08:00
parent b4fef8d828
commit 7d1c0d753d

View File

@@ -26,6 +26,12 @@ in
description = "Whether to enable the TLP power management daemon.";
};
pd = {
enable = lib.mkEnableOption "the power-rofiles-daemon like DBus interface for TLP";
package = lib.mkPackageOption pkgs "tlp-pd" { };
};
settings = lib.mkOption {
type =
with lib.types;
@@ -80,6 +86,23 @@ in
Set `services.tlp.settings.SATA_LINKPWR_ON_AC` and `services.tlp.settings.SATA_LINKPWR_ON_BAT` instead.
'';
}
{
assertion = cfg.pd.enable -> !config.services.power-profiles-daemon.enable;
message = ''
`services.tlp.pd` and `services.power-profiles-daemon` cannot be enabled together,
because they are using the same dbus interface and have the same functionality.
Generally, `services.tlp.pd` should be preferred as upstream does not recommend
using tlp together with power-profiles-daemon.
Set `services.power-profiles-daemon.enable` to `false` to resolve this error.
'';
}
{
assertion = cfg.pd.enable -> !(config.services.tuned.enable && config.services.tuned.ppdSupport);
message = ''
`services.tlp.pd` and `services.tuned.ppdSupport` cannot be enabled together,
because they are using the same dbus interface and have the same functionality.
'';
}
];
environment.etc = {
@@ -90,7 +113,10 @@ in
"${cfg.package}/lib/NetworkManager/dispatcher.d/99tlp-rdw-nm";
};
environment.systemPackages = [ cfg.package ];
environment.systemPackages = [
cfg.package
]
++ lib.optionals cfg.pd.enable [ cfg.pd.package ];
services.tlp.settings =
let
@@ -112,7 +138,11 @@ in
# use native tlp instead because it can also differentiate between AC/BAT
services.cpufreq.enable = false;
packages = [ cfg.package ];
packages = [
cfg.package
]
++ lib.optionals cfg.pd.enable [ cfg.pd.package ];
# XXX: These must always be disabled/masked according to [1].
#
# [1]: https://github.com/linrunner/TLP/blob/a9ada09e0821f275ce5f93dc80a4d81a7ff62ae4/tlp-stat.in#L319