21 , x86_energy_perf_policy
22 # RDW only works with NetworkManager, and thus is optional with default off
25 }: stdenv.mkDerivation rec {
29 src = fetchFromGitHub {
33 hash = "sha256-kjtszDLlnIkBi3yU/AyGSV8q7QBuZbDhsqJ8AvULb0M=";
36 # XXX: See patch files for relevant explanations.
38 ./patches/0001-makefile-correctly-sed-paths.patch
39 ./patches/0002-reintroduce-tlp-sleep-service.patch
42 buildInputs = [ perl ];
43 nativeBuildInputs = [ makeWrapper ];
45 # XXX: While [1] states that DESTDIR should not be used, and that the correct
46 # variable to set is, in fact, PREFIX, tlp thinks otherwise. The Makefile for
47 # tlp concerns itself only with DESTDIR [2] (possibly incorrectly) and so we set
48 # that as opposed to PREFIX, despite what [1] says.
50 # [1]: https://github.com/NixOS/nixpkgs/issues/65718
51 # [2]: https://github.com/linrunner/TLP/blob/ab788abf4936dfb44fbb408afc34af834230a64d/Makefile#L4-L46
57 "DESTDIR=${placeholder "out"}"
58 "TLP_BATD=/share/tlp/bat.d"
60 "TLP_CONFDEF=/share/tlp/defaults.conf"
61 "TLP_CONFREN=/share/tlp/rename.conf"
62 "TLP_FLIB=/share/tlp/func.d"
64 "TLP_META=/share/metainfo"
66 "TLP_SHCPL=/share/bash-completion/completions"
70 installTargets = [ "install-tlp" "install-man" ]
71 ++ lib.optionals enableRDW [ "install-rdw" "install-man-rdw" ];
74 nativeCheckInputs = [ checkbashisms perlcritic shellcheck ];
75 checkTarget = [ "checkall" ];
77 # TODO: Consider using resholve here
79 paths = lib.makeBinPath (
94 ] ++ lib.optional enableRDW networkmanager
95 ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform x86_energy_perf_policy) x86_energy_perf_policy
100 $out/share/tlp/tlp-pcilist
101 $out/share/tlp/tlp-readconfs
102 $out/share/tlp/tlp-usblist
104 for f in "''${fixup_perl[@]}"; do
105 wrapProgram "$f" --prefix PATH : "${paths}"
110 $out/etc/NetworkManager/dispatcher.d/*
113 $out/share/tlp/bat.d/*
114 $out/share/tlp/func.d/*
115 $out/share/tlp/tlp-func-base
117 for f in "''${fixup_bash[@]}"; do
118 sed -i '2iexport PATH=${paths}:$PATH' "$f"
122 rm -rf $out/share/metainfo
126 description = "Advanced Power Management for Linux";
128 "https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html";
129 changelog = "https://github.com/linrunner/TLP/releases/tag/${version}";
130 platforms = platforms.linux;
132 maintainers = with maintainers; [ abbradar lovesegfault ];
133 license = licenses.gpl2Plus;