From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: RFH: Add prosody service Date: Fri, 02 Dec 2016 12:19:44 +0100 Message-ID: <87y3zybmsv.fsf@lassieur.org> References: <874m2uxiuu.fsf@lassieur.org> <87polfl3np.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cClsh-0002Ap-Vk for guix-devel@gnu.org; Fri, 02 Dec 2016 06:19:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cClsd-0007gb-0U for guix-devel@gnu.org; Fri, 02 Dec 2016 06:19:55 -0500 In-reply-to: <87polfl3np.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel Hi Ludovic, >> Here are my problems. >> >> A. A virtualhost-configuration has a lot in common with >> prosody-configuration, and I don't want to repeat stuff. > > What about a record that would have > =E2=80=98global-1=E2=80=99=E2=80=A6=E2=80=98global-N=E2=80=99 fields, p= lus a =E2=80=98virtual-host-settings=E2=80=99 that would > aggregate a ? That wouldn't solve problem B. >> B. Common settings should have a default value in prosody-configuratio= n, >> and be disabled by default in the list of virtualhost-configuration= s. > > Oh, I see. > >> I found two ways to solve this: >> >> 1. One uses "eval" to transform the input of "define-configuration" in= to >> a list that I can build from other lists. >> >> 2. The other uses a macro that takes define-configuration's input, plu= s >> a tag (called target) describing whether it's a global, common, or >> virtualhost specific field. Then the macro calls >> define-configuration many times, each time with a subset of the >> original input, filtered with a specific tag ("global", >> "virtualhost") plus the "common" tag. >> (Its name is define-all-configurations.) > > I think you could always write a =E2=80=98define-common-configurations=E2= =80=99 macro on > top of =E2=80=98define-configuration=E2=80=99 that would let you specif= y two default > values: one for the global context, and one for the virtual-host > contexts. (Thus, no need for =E2=80=98eval=E2=80=99: the code is gener= ated at macro > expansion time.) > > Would that work? That's kind of what I did here: http://lists.gnu.org/archive/html/guix-devel/2016-11/msg01075.html The macro 'define-all-configurations' defines two default values: one for the global context (def) and one for the virtual-host context ('disabled). (The macro I did also changes the doc and the type, depending on whether it's a virtualhost or not.) > It would allow you to avoid repeating field definitions, but you=E2=80=99= d end > up with two almost identical record types that are completely disjoint > (no inheritance in particular.) This may or may not be desirable. > > For record type inheritance, we=E2=80=99d need SRFI-99 or something equ= ivalent. Which is not implemented by Guile, is it? So is what I did desirable? Or maybe should we wait until we have something similar to SRFI-99, and use opaque-prosody-configuration only? >> There's another issue: how to represent fields that we don't want to >> serialize (see problem B). I define a macro (define-maybe) that adds = to >> a field the possibility to have the value 'disabled. But there are >> plenty of other ways to do, I could do differently, just tell me. The= re >> is this thread talking about it: >> http://lists.gnu.org/archive/html/guix-devel/2016-11/msg01024.html. > > Looking at (gnu services mail), you can define custom field types with > associated serializers. > > So you could define a =E2=80=98maybe-string=E2=80=99 type, say, with an= associated > serializer. > > How does that sound? That's also what I did here: http://lists.gnu.org/archive/html/guix-devel/2016-11/msg01075.html --=20 Cl=C3=A9ment