summary refs log tree commit diff
path: root/gnu/services/configuration.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/configuration.scm')
-rw-r--r--gnu/services/configuration.scm45
1 files changed, 34 insertions, 11 deletions
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 21cb829382..f23840ee6d 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -44,10 +44,12 @@
             configuration-error?
 
             define-configuration
+            define-configuration/no-serialization
             no-serialization
 
             serialize-configuration
             define-maybe
+            define-maybe/no-serialization
             validate-configuration
             generate-documentation
             configuration->documentation
@@ -107,20 +109,34 @@ does not have a default value" field kind)))
   "Assemble PARTS into a raw (unhygienic) identifier."
   (datum->syntax ctx (symbol-append (syntax->datum parts) ...)))
 
+(define (define-maybe-helper serialize? syn)
+  (syntax-case syn ()
+    ((_ stem)
+     (with-syntax
+         ((stem?            (id #'stem #'stem #'?))
+          (maybe-stem?      (id #'stem #'maybe- #'stem #'?))
+          (serialize-stem   (id #'stem #'serialize- #'stem))
+          (serialize-maybe-stem (id #'stem #'serialize-maybe- #'stem)))
+       #`(begin
+           (define (maybe-stem? val)
+             (or (eq? val 'disabled) (stem? val)))
+           #,@(if serialize?
+                  (list #'(define (serialize-maybe-stem field-name val)
+                            (if (stem? val)
+                                (serialize-stem field-name val)
+                                "")))
+                  '()))))))
+
 (define-syntax define-maybe
   (lambda (x)
-    (syntax-case x ()
+    (syntax-case x (no-serialization)
+      ((_ stem (no-serialization))
+       (define-maybe-helper #f #'(_ stem)))
       ((_ stem)
-       (with-syntax
-           ((stem?                (id #'stem #'stem #'?))
-            (maybe-stem?          (id #'stem #'maybe- #'stem #'?))
-            (serialize-stem       (id #'stem #'serialize- #'stem))
-            (serialize-maybe-stem (id #'stem #'serialize-maybe- #'stem)))
-         #'(begin
-             (define (maybe-stem? val)
-               (or (eq? val 'disabled) (stem? val)))
-             (define (serialize-maybe-stem field-name val)
-               (if (stem? val) (serialize-stem field-name val) ""))))))))
+       (define-maybe-helper #t #'(_ stem))))))
+
+(define-syntax-rule (define-maybe/no-serialization stem)
+  (define-maybe stem (no-serialization)))
 
 (define (define-configuration-helper serialize? syn)
   (syntax-case syn ()
@@ -207,6 +223,13 @@ does not have a default value" field kind)))
          #t #'(_ stem (field (field-type def ...) doc custom-serializer ...)
                  ...))))))
 
+(define-syntax-rule (define-configuration/no-serialization
+                      stem (field (field-type def ...)
+                                  doc custom-serializer ...) ...)
+  (define-configuration stem (field (field-type def ...)
+                                    doc custom-serializer ...) ...
+    (no-serialization)))
+
 (define (empty-serializer field-name val) "")
 (define serialize-package empty-serializer)