Merge pull request #5531 from abbradar/tlp

tlp: add package
This commit is contained in:
Domen Kožar 2015-01-24 07:10:48 +01:00
commit fde45d217e
4 changed files with 163 additions and 0 deletions

View File

@ -149,6 +149,7 @@
./services/hardware/pommed.nix
./services/hardware/sane.nix
./services/hardware/tcsd.nix
./services/hardware/tlp.nix
./services/hardware/thinkfan.nix
./services/hardware/udev.nix
./services/hardware/udisks2.nix

View File

@ -0,0 +1,93 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.tlp;
tlp = pkgs.tlp.override { kmod = config.system.sbin.modprobe; };
confFile = pkgs.writeText "tlp" (builtins.readFile "${tlp}/etc/default/tlp" + cfg.extraConfig);
in
{
###### interface
options = {
services.tlp = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the TLP daemon.";
};
extraConfig = mkOption {
type = types.str;
default = "";
description = "Additional configuration variables for TLP";
};
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services = {
tlp = {
description = "TLP system startup/shutdown";
after = [ "multi-user.target" ];
wantedBy = [ "multi-user.target" ];
before = [ "shutdown.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${tlp}/bin/tlp init start";
ExecStop = "${tlp}/bin/tlp init stop";
};
};
tlp-sleep = {
description = "TLP suspend/resume";
wantedBy = [ "sleep.target" ];
before = [ "sleep.target" ];
unitConfig = {
StopWhenUnneeded = true;
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${tlp}/bin/tlp suspend";
ExecStop = "${tlp}/bin/tlp resume";
};
};
};
services.udev.packages = [ tlp ];
environment.etc = [{ source = confFile;
target = "default/tlp";
}
] ++ optional tlp.enableRDW {
source = "${tlp}/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm";
target = "NetworkManager/dispatcher.d/99tlp-rdw-nm";
};
environment.systemPackages = [ tlp ];
};
}

View File

@ -0,0 +1,65 @@
{ stdenv, fetchFromGitHub, makeWrapper, perl, systemd, iw, rfkill, hdparm, ethtool, inetutils, kmod
, enableRDW ? true, networkmanager }:
let version = "0.6";
in stdenv.mkDerivation {
inherit enableRDW;
name = "tlp-${version}";
src = fetchFromGitHub {
owner = "linrunner";
repo = "TLP";
rev = "${version}";
sha256 = "1kfm6x5w9vica2i13vfckza4fad4wv8ivr40fws3qa6d5jbyx0fy";
};
makeFlags = [ "DESTDIR=$(out)"
"TLP_LIBDIR=/lib"
"TLP_SBIN=/bin"
"TLP_BIN=/bin"
"TLP_NO_INIT=1"
"TLP_NO_PMUTILS=1"
];
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ perl ];
paths = with stdenv.lib;
concatMapStringsSep ":" (x: "${x}/bin")
([ iw rfkill hdparm ethtool inetutils systemd kmod ]
++ optional enableRDW networkmanager
);
installTargets = [ "install-tlp" ] ++ stdenv.lib.optional enableRDW "install-rdw";
postInstall = ''
for i in $out/bin/* $out/lib/udev/tlp-*; do
sed -i "s,/usr/lib/,$out/lib/,g" "$i"
wrapProgram "$i" \
--prefix PATH : "$paths"
done
if [ "$enableRDW" = "1" ]; then
for i in $out/etc/NetworkManager/dispatcher.d/*; do
sed -i "s,/usr/lib/,$out/lib/,g" "$i"
wrapProgram "$i" \
--prefix PATH : "$paths"
done
fi
for i in $out/lib/udev/rules.d/*; do
sed -i "s,RUN+=\",\\0$out,g; s,/usr/sbin,/bin,g" "$i"
done
'';
passthru = { inherit enableRDW; };
meta = with stdenv.lib; {
description = "Advanced Power Management for Linux";
homepage = "http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html";
platforms = platforms.linux;
maintainers = with maintainers; [ abbradar ];
license = licenses.gpl2Plus;
};
}

View File

@ -11210,6 +11210,10 @@ let
tla = callPackage ../applications/version-management/arch { };
tlp = callPackage ../tools/misc/tlp {
enableRDW = config.networking.networkmanager.enable or false;
};
todo-txt-cli = callPackage ../applications/office/todo.txt-cli { };
tomahawk = callPackage ../applications/audio/tomahawk {