Subject: [PATCH] services: tlp: Make destructor return #f on success.

From: Nigko Yerden <[email-masked]>
Date: Tue, 8 Apr 2025 11:30:24 +0500

* gnu/services/pm.scm (tlp-shepherd-service): Make destructor
return #f on success. Destructor "should return #f if it is
now possible again to start the service at a later point"
(shepherd manual).

Change-Id: Ic0d21d32af158da1ae940d9c32c05a3471767764
---
Without this patch tlp service brings annoying messages "Service tlp might
have failed to stop" to the system log. Thanks to lfam and Rutherther on
IRC for mentioning in relation to other service that the destructor of a
shepherd service should return #f on success.

 gnu/services/pm.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index e022437748..12f05b4b33 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Mathieu Othacehe <[email-masked]>
 ;;; Copyright © 2024 Dariqq <[email-masked]>
 ;;; Copyright © 2024 Ian Eure <[email-masked]>
+;;; Copyright © 2025 Nigko Yerden <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -459,15 +460,17 @@ (define-configuration tlp-configuration
 (define (tlp-shepherd-service config)
   (let* ((tlp-bin (file-append
                    (tlp-configuration-tlp config) "/sbin/tlp"))
-         (tlp-action (lambda args
+         (tlp-action (lambda (return-value-on-success . args)
                        #~(lambda _
-                           (zero? (system* #$tlp-bin #$@args))))))
+                           (if (zero? (system* #$tlp-bin #$@args))
+                               #$return-value-on-success
+                               (not #$return-value-on-success))))))
     (list (shepherd-service
            (documentation "Run TLP script.")
            (provision '(tlp))
            (requirement '(user-processes))
-           (start (tlp-action "init" "start"))
-           (stop  (tlp-action "init" "stop"))))))
+           (start (tlp-action #t "init" "start"))
+           (stop  (tlp-action #f "init" "stop"))))))
 
 (define (tlp-activation config)
   (let* ((config-str (with-output-to-string

base-commit: c9524b5841a057b5e64abf0dca75261e741949c5
-- 
2.49.0