[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add a way to disable serialization support to (guix services configu
From: |
Maxim Cournoyer |
Subject: |
Re: Add a way to disable serialization support to (guix services configuration) |
Date: |
Wed, 21 Apr 2021 13:14:00 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Hello again,
Ludovic Courtès <ludo@gnu.org> writes:
[...]
> diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
> index 90f12a8d39..20e1647335 100644
> --- a/gnu/services/configuration.scm
> +++ b/gnu/services/configuration.scm
> @@ -109,6 +109,9 @@
> (define (serialize-maybe-stem field-name val)
> (if (stem? val) (serialize-stem field-name val) ""))))))))
>
> +(define-syntax-parameter configuration-field-serialization?
> + (identifier-syntax #t))
> +
> (define-syntax define-configuration
> (lambda (stx)
> (syntax-case stx ()
> @@ -123,7 +126,8 @@
> #'(field-type ...)))
> ((field-serializer ...)
> (map (lambda (type)
> - (id #'stem #'serialize- type))
> + #`(and configuration-field-serialization?
> + #,(id #'stem #'serialize- type)))
> #'(field-type ...))))
> #`(begin
> (define-record-type* #,(id #'stem #'< #'stem #'>)
> @@ -152,6 +156,16 @@
> #,(id #'stem #'stem #'-fields))
> conf))))))))
>
> +(define-syntax-rule (without-field-serialization definition)
> + (syntax-parameterize ((configuration-field-serialization?
> + (identifier-syntax #f)))
> + definition
> + #t))
> +
> +(without-field-serialization
> + (define-configuration foo
> + (bar (integer 123) "doc")))
> +
> (define (serialize-package field-name val)
> "")
Actually, this doesn't seem to work; when exporting the
'without-field-serialization' from this module and using it in another
module (wrapping a (define-configuration ...) form), the compiler
complains that the 'foo' variable is not defined; perhaps because foo is
exported as part of the module definition?
If you have an idea why, hints welcome.
Maxim