aboutsummaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2024-06-22 15:31:16 +0200
committerLudovic Courtès <ludo@gnu.org>2024-06-26 22:51:25 +0200
commit0a220c1599613b7bee38c0bf8bc1bb3e9cbcaeb8 (patch)
tree7cdf9d12ef98863780bb8b9982e0902b4751d3ba /gnu/services
parent0fdac5f036fe038d7e7c5555252c0d3467035d44 (diff)
downloadguix-0a220c1599613b7bee38c0bf8bc1bb3e9cbcaeb8.tar
guix-0a220c1599613b7bee38c0bf8bc1bb3e9cbcaeb8.tar.gz
services: shepherd: Support “free-form” services.
* gnu/services/shepherd.scm (<shepherd-service>)[free-form]: New field. [start]: Add default value. (shepherd-service-file): Rename to… (shepherd-service-file/regular): … this. (shepherd-service-file/free-form): New procedure. (shepherd-service-file): Dispatch to one of the two procedures above. * doc/guix.texi (Shepherd Services): Document the ‘free-form’ field. Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Change-Id: I206374e950ef6d1e4a996c0f507fb5fcd9cadde3
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/shepherd.scm25
1 files changed, 22 insertions, 3 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index ccc8e61a33..05534ab317 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -60,6 +60,7 @@
shepherd-service-respawn?
shepherd-service-start
shepherd-service-stop
+ shepherd-service-free-form
shepherd-service-auto-start?
shepherd-service-modules
@@ -217,7 +218,10 @@ DEFAULT is given, use it as the service's default value."
(default #f))
(respawn-delay shepherd-service-respawn-delay
(default #f))
- (start shepherd-service-start) ;g-expression (procedure)
+ (free-form shepherd-service-free-form ;#f | g-expression (service)
+ (default #f))
+ (start shepherd-service-start ;g-expression (procedure)
+ (default #~(const #t)))
(stop shepherd-service-stop ;g-expression (procedure)
(default #~(const #f)))
(actions shepherd-service-actions ;list of <shepherd-action>
@@ -298,8 +302,8 @@ stored."
provisions)
".scm")))
-(define (shepherd-service-file service)
- "Return a file defining SERVICE."
+(define (shepherd-service-file/regular service)
+ "Return a file defining SERVICE, a service whose 'free-form' field is #f."
(scheme-file (shepherd-service-file-name service)
(with-imported-modules %default-imported-modules
#~(begin
@@ -332,6 +336,21 @@ stored."
#~(#$name #$doc #$proc)))
(shepherd-service-actions service))))))))
+(define (shepherd-service-file/free-form service)
+ "Return a file defining SERVICE, a service whose 'free-form' field is set."
+ (scheme-file (shepherd-service-file-name service)
+ (with-imported-modules %default-imported-modules
+ #~(begin
+ (use-modules #$@(shepherd-service-modules service))
+
+ #$(shepherd-service-free-form service)))))
+
+(define (shepherd-service-file service)
+ "Return a file defining SERVICE."
+ (if (shepherd-service-free-form service)
+ (shepherd-service-file/free-form service)
+ (shepherd-service-file/regular service)))
+
(define (scm->go file shepherd)
"Compile FILE, which contains code to be loaded by shepherd's config file,
and return the resulting '.go' file. SHEPHERD is used as shepherd package."