tlp: add x86_energy_perf_policy, refactor

This commit is contained in:
Nikolay Amiantov 2015-11-09 17:24:08 +03:00
parent 265718c985
commit 23845d7084
3 changed files with 25 additions and 21 deletions

View File

@ -6,7 +6,12 @@ let
cfg = config.services.tlp; cfg = config.services.tlp;
tlp = pkgs.tlp.override { kmod = config.system.sbin.modprobe; }; enableRDW = config.networking.networkmanager.enable;
tlp = pkgs.tlp.override {
inherit enableRDW;
kmod = config.system.sbin.modprobe;
};
# XXX: We can't use writeTextFile + readFile here because it triggers # XXX: We can't use writeTextFile + readFile here because it triggers
# TLP build to get the .drv (even on --dry-run). # TLP build to get the .drv (even on --dry-run).
@ -90,13 +95,15 @@ in
environment.etc = [{ source = confFile; environment.etc = [{ source = confFile;
target = "default/tlp"; target = "default/tlp";
} }
] ++ optional tlp.enableRDW { ] ++ optional enableRDW {
source = "${tlp}/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm"; source = "${tlp}/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm";
target = "NetworkManager/dispatcher.d/99tlp-rdw-nm"; target = "NetworkManager/dispatcher.d/99tlp-rdw-nm";
}; };
environment.systemPackages = [ tlp ]; environment.systemPackages = [ tlp ];
boot.kernelModules = [ "msr" ];
}; };
} }

View File

@ -1,11 +1,10 @@
{ stdenv, fetchFromGitHub, makeWrapper, perl, systemd, iw, rfkill, hdparm, ethtool, inetutils, kmod { stdenv, lib, fetchFromGitHub, makeWrapper, perl, systemd, iw, rfkill, hdparm, ethtool, inetutils
, pciutils, smartmontools , kmod, pciutils, smartmontools, x86_energy_perf_policy
, enableRDW ? true, networkmanager }: , enableRDW ? false, networkmanager
}:
let version = "0.8"; let version = "0.8";
in stdenv.mkDerivation { in stdenv.mkDerivation {
inherit enableRDW;
name = "tlp-${version}"; name = "tlp-${version}";
src = fetchFromGitHub { src = fetchFromGitHub {
@ -27,10 +26,11 @@ in stdenv.mkDerivation {
buildInputs = [ perl ]; buildInputs = [ perl ];
paths = with stdenv.lib; paths = lib.makeSearchPath "bin"
concatMapStringsSep ":" (x: "${x}/bin") ([ iw rfkill hdparm ethtool inetutils systemd kmod pciutils smartmontools
([ iw rfkill hdparm ethtool inetutils systemd kmod pciutils smartmontools ] x86_energy_perf_policy
++ optional enableRDW networkmanager ]
++ lib.optional enableRDW networkmanager
); );
installTargets = [ "install-tlp" ] ++ stdenv.lib.optional enableRDW "install-rdw"; installTargets = [ "install-tlp" ] ++ stdenv.lib.optional enableRDW "install-rdw";
@ -41,13 +41,6 @@ in stdenv.mkDerivation {
wrapProgram "$i" \ wrapProgram "$i" \
--prefix PATH : "$paths" --prefix PATH : "$paths"
done 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 for i in $out/lib/udev/rules.d/*; do
sed -i "s,RUN+=\",\\0$out,g; s,/usr/sbin,/bin,g" "$i" sed -i "s,RUN+=\",\\0$out,g; s,/usr/sbin,/bin,g" "$i"
@ -56,10 +49,14 @@ in stdenv.mkDerivation {
for i in man/*; do for i in man/*; do
install -D $i $out/share/man/man''${i##*.}/$(basename $i) install -D $i $out/share/man/man''${i##*.}/$(basename $i)
done done
'' + lib.optionalString enableRDW ''
for i in $out/etc/NetworkManager/dispatcher.d/*; do
sed -i "s,/usr/lib/,$out/lib/,g" "$i"
wrapProgram "$i" \
--prefix PATH : "$paths"
done
''; '';
passthru = { inherit enableRDW; };
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Advanced Power Management for Linux"; description = "Advanced Power Management for Linux";
homepage = "http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html"; homepage = "http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html";

View File

@ -13103,7 +13103,7 @@ let
tla = callPackage ../applications/version-management/arch { }; tla = callPackage ../applications/version-management/arch { };
tlp = callPackage ../tools/misc/tlp { tlp = callPackage ../tools/misc/tlp {
enableRDW = config.networking.networkmanager.enable or false; inherit (linuxPackages) x86_energy_perf_policy;
}; };
todo-txt-cli = callPackage ../applications/office/todo.txt-cli { }; todo-txt-cli = callPackage ../applications/office/todo.txt-cli { };