From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: RFH: Add prosody service Date: Mon, 28 Nov 2016 22:01:46 +0100 Message-ID: <87polfl3np.fsf@gnu.org> References: <874m2uxiuu.fsf@lassieur.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]:52871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBT3g-0004dQ-Is for guix-devel@gnu.org; Mon, 28 Nov 2016 16:01:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBT3d-0003Cj-H9 for guix-devel@gnu.org; Mon, 28 Nov 2016 16:01:52 -0500 In-Reply-To: <874m2uxiuu.fsf@lassieur.org> (=?utf-8?Q?=22Cl=C3=A9ment?= Lassieur"'s message of "Sat, 26 Nov 2016 18:15:53 +0100") 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: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Cc: guix-devel Hi! Cl=C3=A9ment Lassieur skribis: > I'm actually working on the Prosody service, and I am struggling with a > few things. What I did works, but some configurations are probably > missing. I'm not sure I'm doing it the right way, so I would appreciate > a few comments before I go further. > > Here is how a typical .lua Prosody configuration file looks like: > > -- global section -- > > global-1 =3D ... > global-2 =3D ... > common-1 =3D ... > common-2 =3D ... > common-3 =3D ... > > -- virtualhosts section -- > > Virtualhost domain1 > common-1 =3D ... > common-2 =3D ... > common-3 =3D ... > > Virtualhost domain2 > common-1 =3D ... > common-2 =3D ... > common-3 =3D ... > > Settings that are in the global section apply to all virtualhosts. > Settings under each Virtualhost entry apply only to that virtualhost. > > So in Scheme, I implemented this as a prosody-configuration > (representing the whole file), containing: > - global settings, > - common settings, > - a list of virtualhost-configuration. > > 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, plus = a =E2=80=98virtual-host-settings=E2=80=99 that would aggregate a ? > B. Common settings should have a default value in prosody-configuration, > and be disabled by default in the list of virtualhost-configurations. Oh, I see. > I found two ways to solve this: > > 1. One uses "eval" to transform the input of "define-configuration" into > a list that I can build from other lists. > > 2. The other uses a macro that takes define-configuration's input, plus > 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 specify tw= o 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 generated= at macro expansion time.) Would that work? It would allow you to avoid repeating field definitions, but you=E2=80=99d = 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 equival= ent. > 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. There > 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 ass= ociated serializer. How does that sound? That said, I=E2=80=99m not familiar with (gnu services configuration) yet. Ludo=E2=80=99.