From 645e3cb84c16b0c5c3f2bb2418847125644d8f95 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Fri, 31 May 2024 12:45:03 +0200
Subject: [PATCH] head-node: Enable debug logging.

* head-node.scm (cuirass-latest/debug): New variable.
<cuirass-configuration>: Use it.
---
 head-node.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/head-node.scm b/head-node.scm
index a87c43e..6829837 100644
--- a/head-node.scm
+++ b/head-node.scm
@@ -7,7 +7,9 @@
 
 (use-modules (gnu)
              ((guix store) #:select (%store-prefix))
+             (guix packages)
              (guix modules)
+             ((guix utils) #:select (substitute-keyword-arguments))
              (srfi srfi-1)
              (srfi srfi-26)
              (ice-9 match))
@@ -17,6 +19,21 @@
 (use-package-modules certs databases screen ssh web)
 (use-modules ((cuirass-package) #:prefix latest:))
 
+(define cuirass-latest/debug
+  (package/inherit latest:cuirass
+    (arguments
+     (substitute-keyword-arguments (package-arguments latest:cuirass)
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            (add-after 'strip 'enable-debug-logging
+              (lambda* (#:key outputs #:allow-other-keys)
+                (let ((out (assoc-ref outputs "out")))
+                  (substitute* (string-append out "/bin/cuirass")
+                    (("^exec .*" all)
+                     (string-append "\
+export CUIRASS_LOGGING_LEVEL=${CUIRASS_LOGGING_LEVEL:-debug}\n"
+                                    all))))))))))))
+
 (define %custom-base-services
   (modify-services %base-services
     (guix-service-type config =>
@@ -496,7 +513,7 @@
 
                  (service cuirass-service-type
                           (cuirass-configuration
-                           (cuirass latest:cuirass)
+                           (cuirass cuirass-latest/debug)
 
                            ;; By default, poll repositories relatively
                            ;; infrequently.  Send POST requests on
-- 
GitLab