From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1es8IX-0005kE-7t for guix-patches@gnu.org; Sat, 03 Mar 2018 09:38:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1es8IU-0003p2-3A for guix-patches@gnu.org; Sat, 03 Mar 2018 09:38:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:34098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1es8IT-0003ow-Um for guix-patches@gnu.org; Sat, 03 Mar 2018 09:38:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1es8IT-0007Ke-LO for guix-patches@gnu.org; Sat, 03 Mar 2018 09:38:01 -0500 Subject: [bug#30657] [PATCH] services: messaging: Prosody config supports file-like objects. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87o9k6csz9.fsf@gnu.org> <20180303013308.12929-1-clement@lassieur.org> Date: Sat, 03 Mar 2018 15:37:49 +0100 In-Reply-To: <20180303013308.12929-1-clement@lassieur.org> ("=?UTF-8?Q?Cl=C3=A9ment?= Lassieur"'s message of "Sat, 3 Mar 2018 02:33:08 +0100") Message-ID: <87bmg5b4xu.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Cc: 30657@debbugs.gnu.org Hello, Cl=C3=A9ment Lassieur skribis: > * doc/guix.texi (Messaging Services): Update accordingly. > * gnu/services/configuration.scm (serialize-configuration, > serialize-maybe-stem, serialize-package): Return strings or string-valued > gexps (these procedures were only used for their side-effects). > (file-like?): New exported procedure. > * gnu/services/messaging.scm (serialize-field, serialize-field-list, > enclose-quotes, serialize-raw-content, serialize-ssl-configuration, > serialize-virtualhost-configuration-list, > serialize-int-component-configuration-list, > serialize-ext-component-configuration-list, > serialize-virtualhost-configuration, serialize-int-component-configuratio= n, > serialize-ext-component-configuration, serialize-prosody-configuration): > Return strings or string-valued gexps and stop printing. > (prosody-activation): Use SERIALIZE-PROSODY-CONFIGURATION's return value = with > MIXED-TEXT-FILE instead of using its output with PLAIN-FILE. > (serialize-non-negative-integer, serialize-non-negative-integer-list): Co= nvert > numbers to strings. > (file-object?, serialize-file-object, file-object-list?, > serialize-file-object-list): New procedures. > (ssl-configuration)[capath, cafile], (prosody-configuration)[plugin-paths, > groups-file]: Replace FILE-NAME with FILE-OBJECT. [...] > + #~(string-append > + #$@(map (lambda (field) > + ((configuration-field-serializer field) > + (configuration-field-name field) > + ((configuration-field-getter field) config))) > + fields))) Awesome, I find it clearer. :-) > +(define (file-like? val) > + (and (struct? val) ((@@ (guix gexp) lookup-compiler) val))) I=E2=80=99m not fond of the idea of using @@ in real code. :-) Could you move =E2=80=98file-like?=E2=80=99 to (guix gexp), with a docstrin= g, and with =E2=80=98->bool=E2=80=99 to avoid exposing internal details: (define (file-like? value) (and (struct? value) (->bool (lookup-compiler value)))) ? > +(define (file-object? val) > + (or (file-like? val) (file-name? val))) Do we need this predicate? After all, all we can say is that a file name is necessarily a string (or a string-valued gexp), but a string is not necessarily a file name (IOW there=E2=80=99s no disjoint type for file names.) I suppose the configuration mechanism needs it though, right? In that context it=E2=80=99s probably OK. Apart from this the patch LGTM, thank you! Ludo=E2=80=99.