guix-devel
[Top][All Lists]
Advanced

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

Add a way to disable serialization support to (guix services configurati


From: Maxim Cournoyer
Subject: Add a way to disable serialization support to (guix services configuration)
Date: Mon, 12 Apr 2021 16:57:43 -0400

Hello Guix!

I've rediscovered the little gem that is (guix services configurations),
and attempted to make it more generally useful by adding an option to
opt out of serialization (which is not well adapted for producing a list
of command line arguments from the configuration for example):

--8<---------------cut here---------------start------------->8---
1 file changed, 10 insertions(+), 1 deletion(-)
gnu/services/configuration.scm | 11 ++++++++++-

modified   gnu/services/configuration.scm
@@ -38,6 +38,9 @@
             configuration-field-getter
             configuration-field-default-value-thunk
             configuration-field-documentation
+
+            %with-serialization?
+
             serialize-configuration
             define-maybe
             define-configuration
@@ -51,6 +54,11 @@
 ;;;
 ;;; Code:
 
+;;; XXX: This doesn't actually work as a parameter with macros such as
+;;; define-configuration; it is to be used as a plain global variable.
+;;; Experiments with define-syntax-parameter did not work either.
+(define %with-serialization? (make-parameter #true))
+
 (define-condition-type &configuration-error &error
   configuration-error?)
 
@@ -123,7 +131,8 @@
                            #'(field-type ...)))
                      ((field-serializer ...)
                       (map (lambda (type)
-                             (id #'stem #'serialize- type))
+                             (and (%with-serialization?)
+                                  (id #'stem #'serialize- type)))
                            #'(field-type ...))))
            #`(begin
                (define-record-type* #,(id #'stem #'< #'stem #'>)
--8<---------------cut here---------------end--------------->8---

Unfortunately, it doesn't work, at least when using it from 'guix
system'.  I've also tried a version relying on syntax-parameter instead
of a parameter, with the same result.

Would someone know how it could be made to work?

Thanks,

Maxim



reply via email to

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