unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Add a way to disable serialization support to (guix services configuration)
Date: Sat, 17 Apr 2021 18:29:15 +0200	[thread overview]
Message-ID: <87fszoswmc.fsf@gnu.org> (raw)
In-Reply-To: <878s5ncjaw.fsf@gmail.com> (Maxim Cournoyer's message of "Mon, 12 Apr 2021 16:57:43 -0400")

[-- Attachment #1: Type: text/plain, Size: 715 bytes --]

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?

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.

HTH!

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1493 bytes --]

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)
   "")
 

  reply	other threads:[~2021-04-17 16:29 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 [this message]
2021-04-21 15:43   ` Maxim Cournoyer
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=87fszoswmc.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /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).