tlp-pd: init at 1.9.0 (#475894)

This commit is contained in:
Aleksana
2026-01-01 16:18:40 +00:00
committed by GitHub
3 changed files with 99 additions and 2 deletions

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

View File

@@ -0,0 +1,60 @@
{
lib,
python3Packages,
tlp,
coreutils,
}:
python3Packages.buildPythonApplication {
pname = "tlp-pd";
inherit (tlp)
version
src
patches
postPatch
;
pyproject = false; # Built with make
dependencies = with python3Packages; [
pygobject3
dbus-python
];
makeFlags = [ "DESTDIR=${placeholder "out"}" ];
installTargets = [
"install-pd"
"install-man-pd"
];
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ tlp ]}" ];
postInstall = ''
substituteInPlace $out/share/dbus-1/system-services/*.service \
--replace-fail "/bin/false" "${coreutils}/false"
'';
checkPhase = ''
runHook preCheck
# The program will error out but at least we are not missing python deps
($out/bin/tlpctl --help 2>&1 || true) |\
grep -q 'g-io-error-quark: Could not connect: No such file or directory'
$out/bin/tlp-pd --help
runHook postCheck
'';
meta = {
inherit (tlp.meta)
homepage
changelog
platforms
maintainers
license
;
description = "Power-rofiles-daemon like DBus interface for TLP";
mainProgram = "tlp-pd";
};
}

View File

@@ -20,10 +20,12 @@
systemd,
udevCheckHook,
util-linux,
glib,
x86_energy_perf_policy,
# RDW only works with NetworkManager, and thus is optional with default off
enableRDW ? false,
networkmanager,
tlp-pd,
}:
stdenv.mkDerivation rec {
pname = "tlp";
@@ -104,6 +106,7 @@ stdenv.mkDerivation rec {
smartmontools
systemd
util-linux
glib # gdbus
]
++ lib.optional enableRDW networkmanager
++ lib.optional (lib.meta.availableOn stdenv.hostPlatform x86_energy_perf_policy) x86_energy_perf_policy
@@ -136,6 +139,10 @@ stdenv.mkDerivation rec {
rm -rf $out/share/metainfo
'';
passthru.tests = {
inherit tlp-pd;
};
meta = {
description = "Advanced Power Management for Linux";
homepage = "https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html";