2016-05-24 01:08:08 +01:00
|
|
|
{ stdenv, lib, fetchFromGitHub, perl, makeWrapper, systemd, iw, rfkill, hdparm, ethtool, inetutils
|
2016-04-22 08:40:57 +01:00
|
|
|
, kmod, pciutils, smartmontools, x86_energy_perf_policy, gawk, gnugrep, coreutils
|
2015-11-09 14:24:08 +00:00
|
|
|
, enableRDW ? false, networkmanager
|
|
|
|
}:
|
2015-01-02 15:11:29 +00:00
|
|
|
|
2016-05-24 01:01:06 +01:00
|
|
|
let
|
|
|
|
paths = lib.makeBinPath
|
|
|
|
([ iw rfkill hdparm ethtool inetutils systemd kmod pciutils smartmontools
|
|
|
|
x86_energy_perf_policy gawk gnugrep coreutils
|
|
|
|
]
|
|
|
|
++ lib.optional enableRDW networkmanager
|
|
|
|
);
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
2015-01-02 15:11:29 +00:00
|
|
|
name = "tlp-${version}";
|
2016-05-24 01:01:06 +01:00
|
|
|
version = "0.8";
|
2015-01-02 15:11:29 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "linrunner";
|
|
|
|
repo = "TLP";
|
|
|
|
rev = "${version}";
|
2015-10-15 15:03:49 +01:00
|
|
|
sha256 = "19fvk0xz6i2ryf41akk4jg1c4sb4rcyxdl9fr0w4lja7g76d5zww";
|
2015-01-02 15:11:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
makeFlags = [ "DESTDIR=$(out)"
|
|
|
|
"TLP_LIBDIR=/lib"
|
|
|
|
"TLP_SBIN=/bin"
|
|
|
|
"TLP_BIN=/bin"
|
|
|
|
"TLP_NO_INIT=1"
|
|
|
|
"TLP_NO_PMUTILS=1"
|
|
|
|
];
|
|
|
|
|
2016-05-24 01:08:08 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
2015-01-02 15:11:29 +00:00
|
|
|
buildInputs = [ perl ];
|
|
|
|
|
|
|
|
installTargets = [ "install-tlp" ] ++ stdenv.lib.optional enableRDW "install-rdw";
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
for i in $out/bin/* $out/lib/udev/tlp-*; do
|
2016-05-24 01:08:08 +01:00
|
|
|
sed -i "s,/usr/lib/,$out/lib/,g" "$i"
|
|
|
|
if [[ "$(basename "$i")" = tlp-*list ]]; then
|
|
|
|
# Perl script; use wrapProgram
|
|
|
|
wrapProgram "$i" \
|
|
|
|
--prefix PATH : "${paths}"
|
|
|
|
else
|
|
|
|
# Bash script
|
|
|
|
sed -i '2iexport PATH=${paths}:$PATH' "$i"
|
|
|
|
fi
|
2015-01-02 15:11:29 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
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 15:33:04 +01:00
|
|
|
|
|
|
|
for i in man/*; do
|
|
|
|
install -D $i $out/share/man/man''${i##*.}/$(basename $i)
|
|
|
|
done
|
2015-11-09 14:24:08 +00:00
|
|
|
'' + lib.optionalString enableRDW ''
|
|
|
|
for i in $out/etc/NetworkManager/dispatcher.d/*; do
|
2016-05-24 01:01:06 +01:00
|
|
|
sed -i \
|
|
|
|
-e "s,/usr/lib/,$out/lib/,g" \
|
|
|
|
-e '2iexport PATH=${paths}:$PATH' \
|
|
|
|
"$i"
|
2015-11-09 14:24:08 +00:00
|
|
|
done
|
2015-01-02 15:11:29 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|