2015-01-02 16:11:29 +01:00
|
|
|
{ stdenv, fetchFromGitHub, makeWrapper, perl, systemd, iw, rfkill, hdparm, ethtool, inetutils, kmod
|
2015-11-09 14:24:42 +01:00
|
|
|
, pciutils, smartmontools
|
2015-01-02 16:11:29 +01:00
|
|
|
, enableRDW ? true, networkmanager }:
|
|
|
|
|
2015-10-15 16:03:49 +02:00
|
|
|
let version = "0.8";
|
2015-01-02 16:11:29 +01:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
inherit enableRDW;
|
|
|
|
|
|
|
|
name = "tlp-${version}";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "linrunner";
|
|
|
|
repo = "TLP";
|
|
|
|
rev = "${version}";
|
2015-10-15 16:03:49 +02:00
|
|
|
sha256 = "19fvk0xz6i2ryf41akk4jg1c4sb4rcyxdl9fr0w4lja7g76d5zww";
|
2015-01-02 16:11:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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")
|
2015-11-09 14:24:42 +01:00
|
|
|
([ iw rfkill hdparm ethtool inetutils systemd kmod pciutils smartmontools ]
|
2015-01-02 16:11:29 +01:00
|
|
|
++ 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
|
2015-08-23 16:33:04 +02:00
|
|
|
|
|
|
|
for i in man/*; do
|
|
|
|
install -D $i $out/share/man/man''${i##*.}/$(basename $i)
|
|
|
|
done
|
2015-01-02 16:11:29 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|