all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Clément Lassieur" <clement@lassieur.org>
To: 30657@debbugs.gnu.org
Subject: [bug#30657] [PATCH] services: messaging: Prosody config supports file-like objects.
Date: Sat, 03 Mar 2018 12:43:28 +0100	[thread overview]
Message-ID: <871sh1mljz.fsf@lassieur.org> (raw)
In-Reply-To: <20180303013308.12929-1-clement@lassieur.org>

With a better use of 'format'...

Clément Lassieur <clement@lassieur.org> writes:

>  (define (serialize-field field-name val)
> -  (format #t "~a = ~a;\n" (uglify-field-name field-name) val))
> +  #~(string-append
> +     #$(format #f "~a = " (uglify-field-name field-name)) #$val ";\n"))

#~(format #f "~a = ~a;\n" #$(uglify-field-name field-name) #$val))

>  (define (serialize-field-list field-name val)
>    (serialize-field field-name
> -                   (with-output-to-string
> -                     (lambda ()
> -                       (format #t "{\n")
> -                       (for-each (lambda (x)
> -                                   (format #t "~a;\n" x))
> -                                 val)
> -                       (format #t "}")))))
> +                   #~(string-append
> +                      "{\n"
> +                      #$@(map (lambda (x)
> +                                #~(string-append #$x ";\n"))
> +                              val)
> +                      "}")))

(ice-9 format) can do miracles ;-)

(serialize-field field-name #~(format #f "{\n~@{~a;\n~}}" #$@val)))

>  (define (enclose-quotes s)
> -  (format #f "\"~a\"" s))
> +  #~(string-append "\"" #$s "\""))

#~(format #f "\"~a\"" #$s))

> @@ -273,9 +285,10 @@ can create such a file with:
>     (maybe-string 'disabled)
>     "Password for encrypted private keys."))
>  (define (serialize-ssl-configuration field-name val)
> -  (format #t "ssl = {\n")
> -  (serialize-configuration val ssl-configuration-fields)
> -  (format #t "};\n"))
> +  #~(string-append
> +     "ssl = {\n"
> +     #$(serialize-configuration val ssl-configuration-fields)
> +     "};\n"))

#~(format #f "ssl = {\n~a};\n"
          #$(serialize-configuration val ssl-configuration-fields)))

>  (define-configuration opaque-prosody-configuration
>    (prosody
> @@ -646,13 +666,10 @@ See also @url{https://prosody.im/doc/modules/mod_muc}."
>           (default-certs-dir "/etc/prosody/certs")
>           (data-path (prosody-configuration-data-path config))
>           (pidfile-dir (dirname (prosody-configuration-pidfile config)))
> -         (config-str
> -          (if (opaque-prosody-configuration? config)
> -              (opaque-prosody-configuration-prosody.cfg.lua config)
> -              (with-output-to-string
> -                (lambda ()
> -                  (serialize-prosody-configuration config)))))
> -         (config-file (plain-file "prosody.cfg.lua" config-str)))
> +         (config-str (if (opaque-prosody-configuration? config)
> +                         (opaque-prosody-configuration-prosody.cfg.lua config)
> +                         (serialize-prosody-configuration config)))
> +         (config-file (mixed-text-file "prosody.cfg.lua" config-str)))
>      #~(begin
>          (use-modules (guix build utils))
>          (define %user (getpw "prosody"))

                   (with-imported-modules '((ice-9 format))
                     #~(begin
                         (use-modules (ice-9 format))
                         #$(serialize-prosody-configuration config)))))

  reply	other threads:[~2018-03-03 11:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 22:25 [bug#30657] Add support for file-like objects to the Prosody configuration Clément Lassieur
2018-02-28 22:28 ` [bug#30657] [PATCH 1/4] services: utils: Add 'push-tokens' and 'with-tokens-to-list' Clément Lassieur
2018-02-28 22:28   ` [bug#30657] [PATCH 2/4] gexp: Add 'file-like?' Clément Lassieur
2018-03-02 16:51     ` Ludovic Courtès
2018-03-03  1:44       ` Clément Lassieur
2018-03-03 14:38         ` Ludovic Courtès
2018-02-28 22:28   ` [bug#30657] [PATCH 3/4] services: utils: move 'flatten' from (gnu services web) Clément Lassieur
2018-02-28 22:28   ` [bug#30657] [PATCH 4/4] services: messaging: Prosody config supports file-like objects Clément Lassieur
2018-03-02 17:00 ` [bug#30657] Add support for file-like objects to the Prosody configuration Ludovic Courtès
2018-03-03  1:33   ` [bug#30657] [PATCH] services: messaging: Prosody config supports file-like objects Clément Lassieur
2018-03-03 11:43     ` Clément Lassieur [this message]
2018-03-03 14:27       ` Ludovic Courtès
2018-03-03 14:37     ` Ludovic Courtès
2018-03-03 17:38       ` bug#30657: " Clément Lassieur
2018-03-03  1:40   ` [bug#30657] Add support for file-like objects to the Prosody configuration Clément Lassieur

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871sh1mljz.fsf@lassieur.org \
    --to=clement@lassieur.org \
    --cc=30657@debbugs.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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.