guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/03: home: shepherd: Add daemonize? option to configuration.


From: guix-commits
Subject: 02/03: home: shepherd: Add daemonize? option to configuration.
Date: Wed, 14 Sep 2022 11:28:39 -0400 (EDT)

abcdw pushed a commit to branch master
in repository guix.

commit 6cdde65bb53b439f25f007df238f549ba2debc72
Author: Andrew Tropin <andrew@trop.in>
AuthorDate: Tue Sep 13 08:58:54 2022 +0300

    home: shepherd: Add daemonize? option to configuration.
    
    * gnu/home/services/shepherd.scm (home-shepherd-configuration):
    Add DAEMONIZE?.
    (home-shepherd-configuration-file): Use CONFIG argument instead of two
    separate SERVICES and SHEPHERD, respect DAEMONIZE?.
    (ensure-shepherd-gexp, launch-shepherd-gexp,
    shepherd-xdg-configuration-files): Adjust according to arguments changes in
    HOME-SHEPHERD-CONFIGURATION-FILE.
---
 gnu/home/services/shepherd.scm | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm
index fcc7763a61..d2a803279f 100644
--- a/gnu/home/services/shepherd.scm
+++ b/gnu/home/services/shepherd.scm
@@ -54,19 +54,22 @@
             (default shepherd-0.9)) ; package
   (auto-start? home-shepherd-configuration-auto-start?
                (default #t))
+  (daemonize? home-shepherd-configuration-daemonize?
+              (default #t))
   (services home-shepherd-configuration-services
             (default '())))
 
-(define (home-shepherd-configuration-file services shepherd)
+(define (home-shepherd-configuration-file config)
   "Return the shepherd configuration file for SERVICES.  SHEPHERD is used
 as shepherd package."
-  (assert-valid-graph services)
-
-  (let ((files (map shepherd-service-file services))
-        ;; TODO: Add compilation of services, it can improve start
-        ;; time.
-        ;; (scm->go (cute scm->go <> shepherd))
-        )
+  (let* ((daemonize? (home-shepherd-configuration-daemonize? config))
+         (services (home-shepherd-configuration-services config))
+         (_ (assert-valid-graph services))
+         (files (map shepherd-service-file services))
+         ;; TODO: Add compilation of services, it can improve start
+         ;; time.
+         ;; (scm->go (cute scm->go <> shepherd))
+         )
     (define config
       #~(begin
           (use-modules (srfi srfi-34)
@@ -76,7 +79,11 @@ as shepherd package."
            (map
             (lambda (file) (load file))
             '#$files))
-          (action 'root 'daemonize)
+
+          #$@(if daemonize?
+                 `((action 'root 'daemonize))
+                 '())
+
           (format #t "Starting services...~%")
           (let ((services-to-start
                  '#$(append-map shepherd-service-provision
@@ -92,8 +99,7 @@ as shepherd package."
     (scheme-file "shepherd.conf" config)))
 
 (define (launch-shepherd-gexp config)
-  (let* ((shepherd (home-shepherd-configuration-shepherd config))
-         (services (home-shepherd-configuration-services config)))
+  (let* ((shepherd (home-shepherd-configuration-shepherd config)))
     (if (home-shepherd-configuration-auto-start? config)
         (with-imported-modules '((guix build utils))
           #~(unless (file-exists?
@@ -104,22 +110,22 @@ as shepherd package."
               (let ((log-dir (or (getenv "XDG_LOG_HOME")
                                  (format #f "~a/.local/var/log"
                                          (getenv "HOME")))))
+                ;; TODO: Remove it, 0.9.2 creates it automatically?
                 ((@ (guix build utils) mkdir-p) log-dir)
                 (system*
                  #$(file-append shepherd "/bin/shepherd")
                  "--logfile"
                  (string-append log-dir "/shepherd.log")
                  "--config"
-                 #$(home-shepherd-configuration-file services shepherd)))))
+                 #$(home-shepherd-configuration-file config)))))
         #~"")))
 
 (define (reload-configuration-gexp config)
-  (let* ((shepherd (home-shepherd-configuration-shepherd config))
-         (services (home-shepherd-configuration-services config)))
+  (let* ((shepherd (home-shepherd-configuration-shepherd config)))
     #~(system*
        #$(file-append shepherd "/bin/herd")
        "load" "root"
-       #$(home-shepherd-configuration-file services shepherd))))
+       #$(home-shepherd-configuration-file config))))
 
 (define (ensure-shepherd-gexp config)
   #~(if (file-exists?
@@ -131,10 +137,7 @@ as shepherd package."
         #$(launch-shepherd-gexp config)))
 
 (define (shepherd-xdg-configuration-files config)
-  (let* ((shepherd (home-shepherd-configuration-shepherd config))
-         (services (home-shepherd-configuration-services config)))
-    `(("shepherd/init.scm"
-       ,(home-shepherd-configuration-file services shepherd)))))
+  `(("shepherd/init.scm" ,(home-shepherd-configuration-file config))))
 
 (define-public home-shepherd-service-type
   (service-type (name 'home-shepherd)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]