push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,150 @@
{
stdenv,
lib,
checkbashisms,
coreutils,
ethtool,
fetchFromGitHub,
gawk,
gnugrep,
gnused,
hdparm,
iw,
kmod,
makeWrapper,
pciutils,
perl,
perlcritic,
shellcheck,
smartmontools,
systemd,
udevCheckHook,
util-linux,
x86_energy_perf_policy,
# RDW only works with NetworkManager, and thus is optional with default off
enableRDW ? false,
networkmanager,
}:
stdenv.mkDerivation rec {
pname = "tlp";
version = "1.8.0";
src = fetchFromGitHub {
owner = "linrunner";
repo = "TLP";
rev = version;
hash = "sha256-Bqg0IwLh3XIVJd2VkPQFDCZ/hVrzRFrRLlSHJXlJGWU=";
};
# XXX: See patch files for relevant explanations.
patches = [
./patches/0001-makefile-correctly-sed-paths.patch
./patches/0002-reintroduce-tlp-sleep-service.patch
];
postPatch = ''
substituteInPlace Makefile --replace-fail ' ?= /usr/' ' ?= /'
'';
buildInputs = [ perl ];
nativeBuildInputs = [
makeWrapper
udevCheckHook
];
# XXX: While [1] states that DESTDIR should not be used, and that the correct
# variable to set is, in fact, PREFIX, tlp thinks otherwise. The Makefile for
# tlp concerns itself only with DESTDIR [2] (possibly incorrectly) and so we set
# that as opposed to PREFIX, despite what [1] says.
#
# [1]: https://github.com/NixOS/nixpkgs/issues/65718
# [2]: https://github.com/linrunner/TLP/blob/ab788abf4936dfb44fbb408afc34af834230a64d/Makefile#L4-L46
makeFlags = [
"TLP_NO_INIT=1"
"TLP_WITH_ELOGIND=0"
"TLP_WITH_SYSTEMD=1"
"DESTDIR=${placeholder "out"}"
];
installTargets = [
"install-tlp"
"install-man"
]
++ lib.optionals enableRDW [
"install-rdw"
"install-man-rdw"
];
doCheck = true;
nativeCheckInputs = [
checkbashisms
perlcritic
shellcheck
];
checkTarget = [ "checkall" ];
doInstallCheck = true;
# TODO: Consider using resholve here
postInstall =
let
paths = lib.makeBinPath (
[
coreutils
ethtool
gawk
gnugrep
gnused
hdparm
iw
kmod
pciutils
perl
smartmontools
systemd
util-linux
]
++ lib.optional enableRDW networkmanager
++ lib.optional (lib.meta.availableOn stdenv.hostPlatform x86_energy_perf_policy) x86_energy_perf_policy
);
in
''
fixup_perl=(
$out/share/tlp/tlp-pcilist
$out/share/tlp/tlp-readconfs
$out/share/tlp/tlp-usblist
)
for f in "''${fixup_perl[@]}"; do
wrapProgram "$f" --prefix PATH : "${paths}"
done
fixup_bash=(
$out/bin/*
$out/etc/NetworkManager/dispatcher.d/*
$out/lib/udev/tlp-*
$out/sbin/*
$out/share/tlp/bat.d/*
$out/share/tlp/func.d/*
$out/share/tlp/tlp-func-base
)
for f in "''${fixup_bash[@]}"; do
sed -i '2iexport PATH=${paths}:$PATH' "$f"
done
rm -rf $out/var
rm -rf $out/share/metainfo
'';
meta = with lib; {
description = "Advanced Power Management for Linux";
homepage = "https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html";
changelog = "https://github.com/linrunner/TLP/releases/tag/${version}";
platforms = platforms.linux;
mainProgram = "tlp";
maintainers = with maintainers; [
lovesegfault
];
license = licenses.gpl2Plus;
};
}

View File

@@ -0,0 +1,54 @@
From 6500d02a70572f94e7b7df4d70b391ac27ac8bcb Mon Sep 17 00:00:00 2001
From: Bernardo Meurer <bernardo@meurer.org>
Date: Fri, 15 Oct 2021 23:22:50 -0700
Subject: [PATCH 1/2] makefile: correctly sed paths
The default Makefile for tlp makes a mess with catenating `DESTDIR` to
everything, but then not actualy using the catenated (_ prefixed)
variables to sed it's `.in` files.
This patch makes sure that it correctly sets the paths, taking `DESTDIR`
in account where it makes sense (e.g. /bin where we want $out/bin) but
not where it doesn't (/etc/tlp.conf should be just that).
The reason DESTDIR is used at all, as opposed to the more appropriate
PREFIX, is covered in the nix formula, and is (also) due to the Makefile
being a bit "different."
---
Makefile | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index 41eb38d..df3abb7 100644
--- a/Makefile
+++ b/Makefile
@@ -57,17 +57,17 @@ _VAR = $(DESTDIR)$(TLP_VAR)
SED = sed \
-e "s|@TLPVER@|$(TLPVER)|g" \
- -e "s|@TLP_SBIN@|$(TLP_SBIN)|g" \
- -e "s|@TLP_TLIB@|$(TLP_TLIB)|g" \
- -e "s|@TLP_FLIB@|$(TLP_FLIB)|g" \
- -e "s|@TLP_ULIB@|$(TLP_ULIB)|g" \
- -e "s|@TLP_BATD@|$(TLP_BATD)|g" \
+ -e "s|@TLP_SBIN@|$(_SBIN)|g" \
+ -e "s|@TLP_TLIB@|$(_TLIB)|g" \
+ -e "s|@TLP_FLIB@|$(_FLIB)|g" \
+ -e "s|@TLP_ULIB@|$(_ULIB)|g" \
+ -e "s|@TLP_BATD@|$(_BATD)|g" \
-e "s|@TLP_CONFUSR@|$(TLP_CONFUSR)|g" \
-e "s|@TLP_CONFDIR@|$(TLP_CONFDIR)|g" \
- -e "s|@TLP_CONFDEF@|$(TLP_CONFDEF)|g" \
- -e "s|@TLP_CONFREN@|$(TLP_CONFREN)|g" \
- -e "s|@TLP_CONFDPR@|$(TLP_CONFDPR)|g" \
- -e "s|@TLP_CONF@|$(TLP_CONF)|g" \
+ -e "s|@TLP_CONFDEF@|$(_CONFDEF)|g" \
+ -e "s|@TLP_CONFREN@|$(_CONFREN)|g" \
+ -e "s|@TLP_CONFDPR@|$(_CONFDPR)|g" \
+ -e "s|@TLP_CONF@|$(_CONF)|g" \
-e "s|@TLP_RUN@|$(TLP_RUN)|g" \
-e "s|@TLP_VAR@|$(TLP_VAR)|g"
--
2.44.1

View File

@@ -0,0 +1,85 @@
From 4ae0e860aa2c8c056379a7b6cc0f7a735de9ab12 Mon Sep 17 00:00:00 2001
From: Bernardo Meurer <bernardo@meurer.org>
Date: Fri, 15 Oct 2021 23:07:40 -0700
Subject: [PATCH 2/2] tlp-sleep.service: reintroduce
This patch reintroduces tlp-sleep as a systemd unit as opposed to a
systemd system-sleep hook script. This is due to the recommendation by
systemd itself to not use the hook scripts. As per the manual:
> Note that scripts or binaries dropped in /usr/lib/systemd/system-sleep/
> are intended for local use only and should be considered hacks. If
> applications want to react to system suspend/hibernation and resume,
> they should rather use the Inhibitor interface[1].
---
Makefile | 6 +++---
tlp-sleep.service.in | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
create mode 100644 tlp-sleep.service.in
diff --git a/Makefile b/Makefile
index df3abb7..5a47001 100644
--- a/Makefile
+++ b/Makefile
@@ -83,6 +83,7 @@ INFILES = \
tlp.rules \
tlp-readconfs \
tlp-run-on \
+ tlp-sleep.service \
tlp.service \
tlp-stat \
tlp.upstart \
@@ -114,7 +115,6 @@ SHFILES = \
tlp-rdw-udev.in \
tlp-rf.in \
tlp-run-on.in \
- tlp-sleep \
tlp-sleep.elogind \
tlp-stat.in \
tlp-usb-udev.in \
@@ -170,7 +170,7 @@ ifneq ($(TLP_NO_INIT),1)
endif
ifneq ($(TLP_WITH_SYSTEMD),0)
install -D -m 644 tlp.service $(_SYSD)/tlp.service
- install -D -m 755 tlp-sleep $(_SDSL)/tlp
+ install -D -m 644 tlp-sleep.service $(_SYSD)/tlp-sleep.service
endif
ifneq ($(TLP_WITH_ELOGIND),0)
install -D -m 755 tlp-sleep.elogind $(_ELOD)/49-tlp-sleep
@@ -253,7 +253,7 @@ uninstall-tlp:
rm $(_ULIB)/rules.d/85-tlp.rules
rm -f $(_SYSV)/tlp
rm -f $(_SYSD)/tlp.service
- rm -f $(_SDSL)/tlp-sleep
+ rm -f $(_SYSD)/tlp-sleep.service
rm -f $(_ELOD)/49-tlp-sleep
rm -f $(_SHCPL)/tlp
rm -f $(_SHCPL)/tlp-stat
diff --git a/tlp-sleep.service.in b/tlp-sleep.service.in
new file mode 100644
index 0000000..79c202c
--- /dev/null
+++ b/tlp-sleep.service.in
@@ -0,0 +1,19 @@
+# tlp - systemd suspend/resume service
+#
+# Copyright (c) 2021 Thomas Koch <linrunner at gmx.net> and others.
+# This software is licensed under the GPL v2 or later.
+
+[Unit]
+Description=TLP suspend/resume
+Before=sleep.target
+StopWhenUnneeded=yes
+Documentation=https://linrunner.de/tlp
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@TLP_SBIN@/tlp suspend
+ExecStop=@TLP_SBIN@/tlp resume
+
+[Install]
+WantedBy=sleep.target
--
2.44.1