summary refs log tree commit diff
path: root/gnu/services/shepherd.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-03-15 11:34:57 +0100
committerLudovic Courtès <ludo@gnu.org>2018-03-15 11:34:57 +0100
commit88cd7bbd3dc8ecb6b02435338eff1524ad7154ed (patch)
tree0fc4040720238c371cddf46ed5b5d35c9ec02eb6 /gnu/services/shepherd.scm
parent61b1dbbdcd87f6b37d6b87715a9a4da4e63485ab (diff)
downloadguix-88cd7bbd3dc8ecb6b02435338eff1524ad7154ed.tar.gz
services: 'shepherd-service-type' now accepts a default value.
* gnu/services/shepherd.scm (shepherd-service-type): Add a second form
with an additional 'default' parameter.
Diffstat (limited to 'gnu/services/shepherd.scm')
-rw-r--r--gnu/services/shepherd.scm26
1 files changed, 18 insertions, 8 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index f7c6983cb0..000e85eb86 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -104,14 +104,24 @@
   ;; <shepherd-service> objects.
   (service shepherd-root-service-type '()))
 
-(define-syntax-rule (shepherd-service-type service-name proc)
-  "Return a <service-type> denoting a simple shepherd service--i.e., the type
-for a service that extends SHEPHERD-ROOT-SERVICE-TYPE and nothing else."
-  (service-type
-   (name service-name)
-   (extensions
-    (list (service-extension shepherd-root-service-type
-                             (compose list proc))))))
+(define-syntax shepherd-service-type
+  (syntax-rules ()
+    "Return a <service-type> denoting a simple shepherd service--i.e., the type
+for a service that extends SHEPHERD-ROOT-SERVICE-TYPE and nothing else.  When
+DEFAULT is given, use it as the service's default value."
+    ((_ service-name proc default)
+     (service-type
+      (name service-name)
+      (extensions
+       (list (service-extension shepherd-root-service-type
+                                (compose list proc))))
+      (default-value default)))
+    ((_ service-name proc)
+     (service-type
+      (name service-name)
+      (extensions
+       (list (service-extension shepherd-root-service-type
+                                (compose list proc))))))))
 
 (define %default-imported-modules
   ;; Default set of modules imported for a service's consumption.