Subject: [PATCH] services: Add error/success service type.

From: Ludovic Courtès <[email-masked]>
Date: Sat, 1 Apr 2023 09:28:42 +0200

* gnu/services/base.scm (error/success-boot-gexp): New procedure.
(error/success-service-type): New variable.
(%base-services): Add an instance of it.
* doc/guix.texi (Base Services): Document it.
---
 doc/guix.texi         | 26 ++++++++++++++++++++++++++
 gnu/services/base.scm | 27 +++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

Hello Guix!

A while back, we committed a change that removed the boot-time
message we’d been seeing, “error in finalization thread: Success”:

  https://git.savannah.gnu.org/cgit/guix.git/commit/?id=168a7933c0e138dc7061a3f0dc96871e16da5c5f

This change was not universally acclaimed.  Some complained that
the boot process had seemingly become opaque because it’s now harder
to tell whether it’s making progress successfully, while others
were disappointed that their newly acquired sticker had become
obsolete.

This patch reinstates that message.  The previous implementation
worked by closing a file descriptor that Guile relied on internally.
The new implementation takes a different approach, with the
error-reporting device implemented right into the service, which
should give us more flexibility—e.g., the service could be extended
to report other error codes.

The new ‘error/success-service-type’ is added to ‘%base-services’,
the default list of system services.  I think it’s good to have it
by default, but that’s something we can discuss.

Feedback welcome!

Ludo’.

diff --git a/doc/guix.texi b/doc/guix.texi
index a58ea8f9ec..605ed648c4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -19007,6 +19007,32 @@ about the Pluggable Authentication Module (PAM) limits, refer to the
 @samp{pam_limits} man page from the @code{linux-pam} package.
 @end defvar
 
+@cindex success, and error (service type)
+@cindex error, and success (service type)
+
+@defvar error/success-service-type
+This is the service type for the iconic ``error in finalization thread:
+Success'' boot-time message that long-time Guix System users are
+familiar with.  It is part of @code{%base-services} (enabled by
+default).
+
+New users who do not feel the need for this service can disable it by
+filtering it out of their service list.  For instance, if you are using
+@code{%desktop-services}, you can change your operating system
+configuration like so (@pxref{Service Reference,
+@code{modify-services}}):
+
+@lisp
+(operating-system
+  ;; @dots{}
+  (services (modify-services %desktop-services
+              (delete error/success-service-type))))
+@end lisp
+
+However, we do not recommend it as you could lose sight of how weird and
+beautiful your system is.
+@end defvar
+
 @defvar greetd-service-type
 @uref{https://git.sr.ht/~kennylevinsen/greetd, @code{greetd}} is a minimal and
 flexible login manager daemon, that makes no assumptions about what you
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index e063828d3b..5479cd63cf 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -248,6 +248,8 @@ (define-module (gnu services base)
             pam-limits-service-type
             pam-limits-service  ; deprecated
 
+            error/success-service-type
+
             greetd-service-type
             greetd-configuration
             greetd-terminal-configuration
@@ -2990,6 +2992,29 @@ (define %qemu-static-networking
    (provision '(networking))
    (name-servers '("10.0.2.3"))))
 
+
+;;;
+;;; The iconic error/success message service.
+;;;
+
+(define (error/success-boot-gexp _)
+  #~(begin
+      (display "error in finalization thread: Success\n"
+               (current-error-port))
+      (sleep 2)))           ;let the user notice--all this hasn't been in vain
+
+(define error/success-service-type
+  (service-type
+   (name 'error/success)
+   (extensions
+    (list (service-extension boot-service-type
+                             error/success-boot-gexp)))
+   (default-value 42)
+   (description
+    "This service prints the iconic error/success message at boot time.  The
+message acts as a lighthouse for seasoned users--and seasoned users to
+be!--who immediately know, when they see it, that everything's alright.")))
+
 
 ;;;
 ;;; greetd-service-type -- minimal and flexible login manager daemon
@@ -3364,6 +3389,8 @@ (define %base-services
 
         (service sysctl-service-type)
 
+        (service error/success-service-type)
+
         (service special-files-service-type
                  `(("/bin/sh" ,(file-append bash "/bin/sh"))
                    ("/usr/bin/env" ,(file-append coreutils "/bin/env"))))))
-- 
2.39.2