2016-11-23 15:07:29 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, perl, makeWrapper, file, systemd, iw, rfkill
|
|
|
|
, hdparm, ethtool, inetutils , kmod, pciutils, smartmontools
|
|
|
|
, x86_energy_perf_policy, gawk, gnugrep, coreutils, utillinux
|
2019-04-03 08:11:41 +01:00
|
|
|
, checkbashisms, shellcheck
|
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
|
2016-11-23 15:07:29 +00:00
|
|
|
x86_energy_perf_policy gawk gnugrep coreutils utillinux
|
2016-05-24 01:01:06 +01:00
|
|
|
]
|
|
|
|
++ lib.optional enableRDW networkmanager
|
|
|
|
);
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
2015-01-02 15:11:29 +00:00
|
|
|
name = "tlp-${version}";
|
2019-05-13 09:43:12 +01:00
|
|
|
version = "1.2.2";
|
2015-01-02 15:11:29 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2019-04-03 08:11:20 +01:00
|
|
|
owner = "linrunner";
|
|
|
|
repo = "TLP";
|
|
|
|
rev = version;
|
2019-05-13 09:43:12 +01:00
|
|
|
sha256 = "0vm31ca6kdak9xzwskz7a8hvdp67drfh2zcdwlz3260r8r2ypgg1";
|
2019-04-03 08:11:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
outRef = placeholder "out";
|
2015-01-02 15:11:29 +00:00
|
|
|
|
2019-04-03 08:11:20 +01:00
|
|
|
makeFlags = [
|
|
|
|
"DESTDIR=${outRef}"
|
|
|
|
"TLP_SBIN=${outRef}/bin"
|
|
|
|
"TLP_BIN=${outRef}/bin"
|
|
|
|
"TLP_TLIB=${outRef}/share/tlp"
|
|
|
|
"TLP_FLIB=${outRef}/share/tlp/func.d"
|
|
|
|
"TLP_ULIB=${outRef}/lib/udev"
|
|
|
|
"TLP_NMDSP=${outRef}/etc/NetworkManager/dispatcher.d"
|
|
|
|
"TLP_SHCPL=${outRef}/share/bash-completion/completions"
|
|
|
|
"TLP_MAN=${outRef}/share/man"
|
|
|
|
"TLP_META=${outRef}/share/metainfo"
|
2016-11-23 15:07:29 +00:00
|
|
|
|
2019-04-03 08:11:20 +01:00
|
|
|
"TLP_NO_INIT=1"
|
|
|
|
];
|
2015-01-02 15:11:29 +00:00
|
|
|
|
2016-11-23 15:07:29 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper file ];
|
2016-05-24 01:08:08 +01:00
|
|
|
|
2015-01-02 15:11:29 +00:00
|
|
|
buildInputs = [ perl ];
|
|
|
|
|
2016-11-23 15:07:29 +00:00
|
|
|
installTargets = [ "install-tlp" "install-man" ] ++ stdenv.lib.optional enableRDW "install-rdw";
|
2015-01-02 15:11:29 +00:00
|
|
|
|
2019-04-03 08:11:41 +01:00
|
|
|
checkInputs = [
|
|
|
|
checkbashisms
|
|
|
|
shellcheck
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkTarget = [ "checkall" ];
|
|
|
|
|
2015-01-02 15:11:29 +00:00
|
|
|
postInstall = ''
|
2016-11-23 15:07:29 +00:00
|
|
|
cp -r $out/$out/* $out
|
|
|
|
rm -rf $out/$(echo "$NIX_STORE" | cut -d "/" -f2)
|
|
|
|
|
|
|
|
for i in $out/bin/* $out/lib/udev/tlp-* ${lib.optionalString enableRDW "$out/etc/NetworkManager/dispatcher.d/*"}; do
|
|
|
|
if file "$i" | grep -q Perl; then
|
2016-05-24 01:08:08 +01:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Advanced Power Management for Linux";
|
2018-06-27 21:12:57 +01:00
|
|
|
homepage = https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html;
|
2015-01-02 15:11:29 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
};
|
|
|
|
}
|