tlp: 1.3.1 -> 1.4.0

+176 -148
+16 -7
pkgs/tools/misc/tlp/default.nix
··· 13 13 , makeWrapper 14 14 , pciutils 15 15 , perl 16 + , perlcritic 16 17 , shellcheck 17 18 , smartmontools 18 19 , systemd ··· 23 24 , networkmanager 24 25 }: stdenv.mkDerivation rec { 25 26 pname = "tlp"; 26 - version = "1.3.1"; 27 + version = "1.4.0"; 27 28 28 29 src = fetchFromGitHub { 29 30 owner = "linrunner"; 30 31 repo = "TLP"; 31 32 rev = version; 32 - sha256 = "14fcnaz9pw534v4d8dddqq4wcvpf1kghr8zlrk62r5lrl46sp1p5"; 33 + sha256 = "sha256-Blwj4cqrrYXohnGyJYe+1NYifxqfS4DoVUHmxFf62i4="; 33 34 }; 34 35 35 36 # XXX: See patch files for relevant explanations. 36 - patches = [ ./patches/fix-makefile-sed.patch ./patches/tlp-sleep-service.patch ]; 37 + patches = [ 38 + ./patches/0001-makefile-correctly-sed-paths.patch 39 + ./patches/0002-tlp-sleep.service-reintroduce.patch 40 + ]; 37 41 38 42 buildInputs = [ perl ]; 39 43 nativeBuildInputs = [ makeWrapper gnused ]; ··· 52 56 "TLP_WITH_ELOGIND=0" 53 57 "TLP_WITH_SYSTEMD=1" 54 58 59 + "TLP_BATD=/share/tlp/bat.d" 55 60 "TLP_BIN=/bin" 56 61 "TLP_CONFDEF=/share/tlp/defaults.conf" 62 + "TLP_CONFREN=/share/tlp/rename.conf" 57 63 "TLP_FLIB=/share/tlp/func.d" 58 64 "TLP_MAN=/share/man" 59 65 "TLP_META=/share/metainfo" ··· 65 71 installTargets = [ "install-tlp" "install-man" ] 66 72 ++ lib.optionals enableRDW [ "install-rdw" "install-man-rdw" ]; 67 73 68 - # XXX: This is disabled because it's basically just noise since upstream 69 - # itself does not seem to care about the zillion shellcheck errors. 70 - doCheck = false; 71 - checkInputs = [ checkbashisms shellcheck ]; 74 + doCheck = true; 75 + checkInputs = [ checkbashisms perlcritic shellcheck ]; 72 76 checkTarget = [ "checkall" ]; 73 77 78 + # TODO: Consider using resholve here 74 79 postInstall = let 75 80 paths = lib.makeBinPath ( 76 81 [ ··· 107 112 $out/etc/NetworkManager/dispatcher.d/* 108 113 $out/lib/udev/tlp-* 109 114 $out/sbin/* 115 + $out/share/tlp/bat.d/* 110 116 $out/share/tlp/func.d/* 111 117 $out/share/tlp/tlp-func-base 112 118 ) 113 119 for f in "''${fixup_bash[@]}"; do 114 120 sed -i '2iexport PATH=${paths}:$PATH' "$f" 115 121 done 122 + 123 + rm -rf $out/var 124 + rm -rf $out/share/metainfo 116 125 ''; 117 126 118 127 meta = with lib; {
+56
pkgs/tools/misc/tlp/patches/0001-makefile-correctly-sed-paths.patch
··· 1 + From 5c5d878bf49bae5920c330482217477819ba9bc2 Mon Sep 17 00:00:00 2001 2 + From: Bernardo Meurer <bernardo@meurer.org> 3 + Date: Fri, 15 Oct 2021 23:22:50 -0700 4 + Subject: [PATCH 1/2] makefile: correctly sed paths 5 + 6 + The default Makefile for tlp makes a mess with catenating `DESTDIR` to 7 + everything, but then not actualy using the catenated (_ prefixed) 8 + variables to sed it's `.in` files. 9 + 10 + This patch makes sure that it correctly sets the paths, taking `DESTDIR` 11 + in account where it makes sense (e.g. /bin where we want $out/bin) but 12 + not where it doesn't (/etc/tlp.conf should be just that). 13 + 14 + The reason DESTDIR is used at all, as opposed to the more appropriate 15 + PREFIX, is covered in the nix formula, and is (also) due to the Makefile 16 + being a bit "different." 17 + --- 18 + Makefile | 18 +++++++++--------- 19 + 1 file changed, 9 insertions(+), 9 deletions(-) 20 + 21 + diff --git a/Makefile b/Makefile 22 + index e9bbab4..ab05720 100644 23 + --- a/Makefile 24 + +++ b/Makefile 25 + @@ -51,19 +51,19 @@ _TPACPIBAT = $(DESTDIR)$(TPACPIBAT) 26 + 27 + SED = sed \ 28 + -e "s|@TLPVER@|$(TLPVER)|g" \ 29 + - -e "s|@TLP_SBIN@|$(TLP_SBIN)|g" \ 30 + - -e "s|@TLP_TLIB@|$(TLP_TLIB)|g" \ 31 + - -e "s|@TLP_FLIB@|$(TLP_FLIB)|g" \ 32 + - -e "s|@TLP_ULIB@|$(TLP_ULIB)|g" \ 33 + - -e "s|@TLP_BATD@|$(TLP_BATD)|g" \ 34 + + -e "s|@TLP_SBIN@|$(_SBIN)|g" \ 35 + + -e "s|@TLP_TLIB@|$(_TLIB)|g" \ 36 + + -e "s|@TLP_FLIB@|$(_FLIB)|g" \ 37 + + -e "s|@TLP_ULIB@|$(_ULIB)|g" \ 38 + + -e "s|@TLP_BATD@|$(_BATD)|g" \ 39 + -e "s|@TLP_CONFUSR@|$(TLP_CONFUSR)|g" \ 40 + -e "s|@TLP_CONFDIR@|$(TLP_CONFDIR)|g" \ 41 + - -e "s|@TLP_CONFDEF@|$(TLP_CONFDEF)|g" \ 42 + - -e "s|@TLP_CONFREN@|$(TLP_CONFREN)|g" \ 43 + - -e "s|@TLP_CONF@|$(TLP_CONF)|g" \ 44 + + -e "s|@TLP_CONFDEF@|$(_CONFDEF)|g" \ 45 + + -e "s|@TLP_CONFREN@|$(_CONFREN)|g" \ 46 + + -e "s|@TLP_CONF@|$(_CONF)|g" \ 47 + -e "s|@TLP_RUN@|$(TLP_RUN)|g" \ 48 + -e "s|@TLP_VAR@|$(TLP_VAR)|g" \ 49 + - -e "s|@TPACPIBAT@|$(TPACPIBAT)|g" 50 + + -e "s|@TPACPIBAT@|$(_TPACPIBAT)|g" 51 + 52 + INFILES = \ 53 + tlp \ 54 + -- 55 + 2.33.0 56 +
+104
pkgs/tools/misc/tlp/patches/0002-tlp-sleep.service-reintroduce.patch
··· 1 + From a3506c9bc8929645b7b08859e47039b8cc830d22 Mon Sep 17 00:00:00 2001 2 + From: Bernardo Meurer <bernardo@meurer.org> 3 + Date: Fri, 15 Oct 2021 23:07:40 -0700 4 + Subject: [PATCH 2/2] tlp-sleep.service: reintroduce 5 + 6 + This patch reintroduces tlp-sleep as a systemd unit as opposed to a 7 + systemd system-sleep hook script. This is due to the recommendation by 8 + systemd itself to not use the hook scripts. As per the manual: 9 + 10 + > Note that scripts or binaries dropped in /usr/lib/systemd/system-sleep/ 11 + > are intended for local use only and should be considered hacks. If 12 + > applications want to react to system suspend/hibernation and resume, 13 + > they should rather use the Inhibitor interface[1]. 14 + --- 15 + Makefile | 6 +++--- 16 + tlp-sleep | 11 ----------- 17 + tlp-sleep.service.in | 19 +++++++++++++++++++ 18 + 3 files changed, 22 insertions(+), 14 deletions(-) 19 + delete mode 100644 tlp-sleep 20 + create mode 100644 tlp-sleep.service.in 21 + 22 + diff --git a/Makefile b/Makefile 23 + index ab05720..075b42f 100644 24 + --- a/Makefile 25 + +++ b/Makefile 26 + @@ -76,6 +76,7 @@ INFILES = \ 27 + tlp.rules \ 28 + tlp-readconfs \ 29 + tlp-run-on \ 30 + + tlp-sleep.service \ 31 + tlp.service \ 32 + tlp-stat \ 33 + tlp.upstart \ 34 + @@ -106,7 +107,6 @@ SHFILES = \ 35 + tlp-rdw-udev.in \ 36 + tlp-rf.in \ 37 + tlp-run-on.in \ 38 + - tlp-sleep \ 39 + tlp-sleep.elogind \ 40 + tlp-stat.in \ 41 + tlp-usb-udev.in 42 + @@ -159,7 +159,7 @@ ifneq ($(TLP_NO_INIT),1) 43 + endif 44 + ifneq ($(TLP_WITH_SYSTEMD),0) 45 + install -D -m 644 tlp.service $(_SYSD)/tlp.service 46 + - install -D -m 755 tlp-sleep $(_SDSL)/tlp 47 + + install -D -m 644 tlp-sleep.service $(_SYSD)/tlp-sleep.service 48 + endif 49 + ifneq ($(TLP_WITH_ELOGIND),0) 50 + install -D -m 755 tlp-sleep.elogind $(_ELOD)/49-tlp-sleep 51 + @@ -216,7 +216,7 @@ uninstall-tlp: 52 + rm $(_ULIB)/rules.d/85-tlp.rules 53 + rm -f $(_SYSV)/tlp 54 + rm -f $(_SYSD)/tlp.service 55 + - rm -f $(_SDSL)/tlp-sleep 56 + + rm -f $(_SYSD)/tlp-sleep.service 57 + rm -f $(_ELOD)/49-tlp-sleep 58 + rm -f $(_SHCPL)/tlp-stat 59 + rm -f $(_SHCPL)/bluetooth 60 + diff --git a/tlp-sleep b/tlp-sleep 61 + deleted file mode 100644 62 + index e548d55..0000000 63 + --- a/tlp-sleep 64 + +++ /dev/null 65 + @@ -1,11 +0,0 @@ 66 + -#!/bin/sh 67 + - 68 + -# tlp - systemd suspend/resume hook 69 + -# 70 + -# Copyright (c) 2021 Thomas Koch <linrunner at gmx.net> and others. 71 + -# This software is licensed under the GPL v2 or later. 72 + - 73 + -case $1 in 74 + - pre) tlp suspend ;; 75 + - post) tlp resume ;; 76 + -esac 77 + diff --git a/tlp-sleep.service.in b/tlp-sleep.service.in 78 + new file mode 100644 79 + index 0000000..79c202c 80 + --- /dev/null 81 + +++ b/tlp-sleep.service.in 82 + @@ -0,0 +1,19 @@ 83 + +# tlp - systemd suspend/resume service 84 + +# 85 + +# Copyright (c) 2021 Thomas Koch <linrunner at gmx.net> and others. 86 + +# This software is licensed under the GPL v2 or later. 87 + + 88 + +[Unit] 89 + +Description=TLP suspend/resume 90 + +Before=sleep.target 91 + +StopWhenUnneeded=yes 92 + +Documentation=https://linrunner.de/tlp 93 + + 94 + +[Service] 95 + +Type=oneshot 96 + +RemainAfterExit=yes 97 + +ExecStart=@TLP_SBIN@/tlp suspend 98 + +ExecStop=@TLP_SBIN@/tlp resume 99 + + 100 + +[Install] 101 + +WantedBy=sleep.target 102 + -- 103 + 2.33.0 104 +
-46
pkgs/tools/misc/tlp/patches/fix-makefile-sed.patch
··· 1 - commit c44347b3b813e209fff537b4d46d23430727a5e2 2 - Author: Bernardo Meurer <meurerbernardo@gmail.com> 3 - Date: Tue Feb 25 21:27:39 2020 -0800 4 - 5 - makefile: correctly sed paths 6 - 7 - The default Makefile for tlp makes a mess with catenating `DESTDIR` to 8 - everything, but then not actualy using the catenated (_ prefixed) 9 - variables to sed it's `.in` files. 10 - 11 - This patch makes sure that it correctly sets the paths, taking `DESTDIR` 12 - in account where it makes sense (e.g. /bin where we want $out/bin) but 13 - not where it doesn't (/etc/tlp.conf should be just that). 14 - 15 - The reason DESTDIR is used at all, as opposed to the more appropriate 16 - PREFIX, is covered in the nix formula, and is (also) due to the Makefile 17 - being a bit "different." 18 - 19 - diff --git a/Makefile b/Makefile 20 - index b5af74e..95122df 100644 21 - --- a/Makefile 22 - +++ b/Makefile 23 - @@ -47,17 +47,17 @@ _TPACPIBAT = $(DESTDIR)$(TPACPIBAT) 24 - 25 - SED = sed \ 26 - -e "s|@TLPVER@|$(TLPVER)|g" \ 27 - - -e "s|@TLP_SBIN@|$(TLP_SBIN)|g" \ 28 - - -e "s|@TLP_TLIB@|$(TLP_TLIB)|g" \ 29 - - -e "s|@TLP_FLIB@|$(TLP_FLIB)|g" \ 30 - - -e "s|@TLP_ULIB@|$(TLP_ULIB)|g" \ 31 - + -e "s|@TLP_SBIN@|$(_SBIN)|g" \ 32 - + -e "s|@TLP_TLIB@|$(_TLIB)|g" \ 33 - + -e "s|@TLP_FLIB@|$(_FLIB)|g" \ 34 - + -e "s|@TLP_ULIB@|$(_ULIB)|g" \ 35 - -e "s|@TLP_CONFUSR@|$(TLP_CONFUSR)|g" \ 36 - -e "s|@TLP_CONFDIR@|$(TLP_CONFDIR)|g" \ 37 - - -e "s|@TLP_CONFDEF@|$(TLP_CONFDEF)|g" \ 38 - + -e "s|@TLP_CONFDEF@|$(_CONFDEF)|g" \ 39 - -e "s|@TLP_CONF@|$(TLP_CONF)|g" \ 40 - -e "s|@TLP_RUN@|$(TLP_RUN)|g" \ 41 - -e "s|@TLP_VAR@|$(TLP_VAR)|g" \ 42 - - -e "s|@TPACPIBAT@|$(TPACPIBAT)|g" 43 - + -e "s|@TPACPIBAT@|$(_TPACPIBAT)|g" 44 - 45 - INFILES = \ 46 - tlp \
-95
pkgs/tools/misc/tlp/patches/tlp-sleep-service.patch
··· 1 - commit ca94cd56210067e2a55c1f413bd7713f7d338f9f 2 - Author: Bernardo Meurer <meurerbernardo@gmail.com> 3 - Date: Wed Feb 26 10:46:23 2020 -0800 4 - 5 - tlp-sleep.service: reintroduce 6 - 7 - This patch reintroduces tlp-sleep as a systemd unit as opposed to a 8 - systemd system-sleep hook script. This is due to the recommendation by 9 - systemd itself to not use the hook scripts. As per the manual: 10 - 11 - > Note that scripts or binaries dropped in /usr/lib/systemd/system-sleep/ 12 - > are intended for local use only and should be considered hacks. If 13 - > applications want to react to system suspend/hibernation and resume, 14 - > they should rather use the Inhibitor interface[1]. 15 - 16 - diff --git a/Makefile b/Makefile 17 - index 95122df..0e9230a 100644 18 - --- a/Makefile 19 - +++ b/Makefile 20 - @@ -70,6 +70,7 @@ INFILES = \ 21 - tlp.rules \ 22 - tlp-readconfs \ 23 - tlp-run-on \ 24 - + tlp-sleep.service \ 25 - tlp.service \ 26 - tlp-stat \ 27 - tlp.upstart \ 28 - @@ -99,7 +100,6 @@ SHFILES = \ 29 - tlp-rdw-udev.in \ 30 - tlp-rf.in \ 31 - tlp-run-on.in \ 32 - - tlp-sleep \ 33 - tlp-sleep.elogind \ 34 - tlp-stat.in \ 35 - tlp-usb-udev.in 36 - @@ -147,7 +147,7 @@ ifneq ($(TLP_NO_INIT),1) 37 - endif 38 - ifneq ($(TLP_WITH_SYSTEMD),0) 39 - install -D -m 644 tlp.service $(_SYSD)/tlp.service 40 - - install -D -m 755 tlp-sleep $(_SDSL)/tlp 41 - + install -D -m 644 tlp-sleep.service $(_SYSD)/tlp-sleep.service 42 - endif 43 - ifneq ($(TLP_WITH_ELOGIND),0) 44 - install -D -m 755 tlp-sleep.elogind $(_ELOD)/49-tlp-sleep 45 - @@ -204,7 +204,7 @@ uninstall-tlp: 46 - rm $(_ULIB)/rules.d/85-tlp.rules 47 - rm -f $(_SYSV)/tlp 48 - rm -f $(_SYSD)/tlp.service 49 - - rm -f $(_SDSL)/tlp-sleep 50 - + rm -f $(_SYSD)/tlp-sleep.service 51 - rm -f $(_ELOD)/49-tlp-sleep 52 - rm -f $(_SHCPL)/tlp-stat 53 - rm -f $(_SHCPL)/bluetooth 54 - diff --git a/tlp-sleep b/tlp-sleep 55 - deleted file mode 100644 56 - index 3de85ce..0000000 57 - --- a/tlp-sleep 58 - +++ /dev/null 59 - @@ -1,11 +0,0 @@ 60 - -#!/bin/sh 61 - - 62 - -# tlp - systemd suspend/resume hook 63 - -# 64 - -# Copyright (c) 2020 Thomas Koch <linrunner at gmx.net> and others. 65 - -# This software is licensed under the GPL v2 or later. 66 - - 67 - -case $1 in 68 - - pre) tlp suspend ;; 69 - - post) tlp resume ;; 70 - -esac 71 - diff --git a/tlp-sleep.service.in b/tlp-sleep.service.in 72 - new file mode 100644 73 - index 0000000..4ac17bd 74 - --- /dev/null 75 - +++ b/tlp-sleep.service.in 76 - @@ -0,0 +1,19 @@ 77 - +# tlp - systemd suspend/resume service 78 - +# 79 - +# Copyright (c) 2020 Thomas Koch <linrunner at gmx.net> and others. 80 - +# This software is licensed under the GPL v2 or later. 81 - + 82 - +[Unit] 83 - +Description=TLP suspend/resume 84 - +Before=sleep.target 85 - +StopWhenUnneeded=yes 86 - +Documentation=https://linrunner.de/tlp 87 - + 88 - +[Service] 89 - +Type=oneshot 90 - +RemainAfterExit=yes 91 - +ExecStart=@TLP_SBIN@/tlp suspend 92 - +ExecStop=@TLP_SBIN@/tlp resume 93 - + 94 - +[Install] 95 - +WantedBy=sleep.target