summaryrefslogtreecommitdiff
path: root/gnu/home/services/shepherd.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-09-15 10:20:32 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-09-15 10:20:32 -0400
commit3d297a0017210f1dd135592efb10846840a8af88 (patch)
tree8868c35a558a6288b5097d65bee42dda291178e4 /gnu/home/services/shepherd.scm
parent279349209e44aaae6ca2aba328fe2a4d2da99f12 (diff)
parent6737d8d3248301e65bc24291b1a776e4aa8c3648 (diff)
Merge branch 'master' into staging
With resolved conflicts in: gnu/local.mk gnu/packages/freedesktop.scm gnu/packages/gnuzilla.scm
Diffstat (limited to 'gnu/home/services/shepherd.scm')
-rw-r--r--gnu/home/services/shepherd.scm42
1 files changed, 27 insertions, 15 deletions
diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm
index 62ab0aadc6..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?
@@ -130,6 +136,9 @@ as shepherd package."
#$(reload-configuration-gexp config)
#$(launch-shepherd-gexp config)))
+(define (shepherd-xdg-configuration-files config)
+ `(("shepherd/init.scm" ,(home-shepherd-configuration-file config))))
+
(define-public home-shepherd-service-type
(service-type (name 'home-shepherd)
(extensions
@@ -137,6 +146,9 @@ as shepherd package."
home-run-on-first-login-service-type
launch-shepherd-gexp)
(service-extension
+ home-xdg-configuration-files-service-type
+ shepherd-xdg-configuration-files)
+ (service-extension
home-activation-service-type
ensure-shepherd-gexp)
(service-extension