From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Add a way to disable serialization support to (guix services configuration)
Date: Wed, 21 Apr 2021 11:43:07 -0400 [thread overview]
Message-ID: <87k0ovd4ok.fsf@gmail.com> (raw)
In-Reply-To: <87fszoswmc.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sat, 17 Apr 2021 18:29:15 +0200")
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> 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):
>
> In the meantime I saw you discuss this on #guile so maybe you’ve solved
> the issue now?
No, thank you for your reply! :-)
> If not, attached is a possible solution and example. It’s not perfect:
> in the example, you’ll get a warning about ‘serialize-integer’ being
> unbound, which is completely harmless but suboptimal. Not sure how to
> address that.
>
> 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)))
I tried:
(if (syntax->datum configuration-field-serialization?)
#,(id #'stem #'serialize- type)
#false)
hoping to get rid of the warning, but that appears to be strictly
equivalent, resulting in the same warning. I also don't know how to fix
that.
> #'(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)
> "")
That does work, thanks! I'm a bit uncomfortable adding more warnings to
the Guix build output; OTOH it provides value (another user recently
pointed to the same annoyance here [0]).
Maxim
[0] https://lists.gnu.org/archive/html/guix-devel/2021-04/msg00319.html
next prev parent reply other threads:[~2021-04-21 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 20:57 Add a way to disable serialization support to (guix services configuration) Maxim Cournoyer
2021-04-17 16:29 ` Ludovic Courtès
2021-04-21 15:43 ` Maxim Cournoyer [this message]
2021-04-22 22:28 ` Ludovic Courtès
2021-04-23 6:09 ` Xinglu Chen
2021-05-01 11:54 ` Xinglu Chen
2021-05-07 5:42 ` Maxim Cournoyer
2021-05-07 14:03 ` Xinglu Chen
2021-05-08 5:08 ` Maxim Cournoyer
2021-04-21 17:14 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0ovd4ok.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).