From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [PATCH] improve nginx-service Date: Fri, 25 Nov 2016 11:53:31 +0100 Message-ID: <87ziknvnis.fsf@lassieur.org> References: <20161016143347.38d8a6f2@polymos.lepiller.eu> <874m483vap.fsf@gnu.org> <20161020143744.516a1184@polymos.lepiller.eu> <87shrlzd0w.fsf@gnu.org> <20161026214507.45445d14@lepiller.eu> <87y41aklqp.fsf@gnu.org> <20161027195949.354cae8e@lepiller.eu> <87pomhse6w.fsf@gnu.org> <87lgx0txz0.fsf@gnu.org> <87h97n1iu0.fsf@gnu.org> <20161104190129.684844b4@lepiller.eu> <20161104231253.4b52d70f@lepiller.eu> <4b44538a-ed70-aacd-4867-5267847aee42@crazy-compilers.com> <87wpgg1q7s.fsf@gnu.org> <20161120134958.109870e3@lepiller.eu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAE8X-0003nL-H4 for guix-devel@gnu.org; Fri, 25 Nov 2016 05:53:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAE8S-0008Rz-LW for guix-devel@gnu.org; Fri, 25 Nov 2016 05:53:45 -0500 Received: from mail.lassieur.org ([83.152.10.219]:47688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cAE8S-0008QN-DS for guix-devel@gnu.org; Fri, 25 Nov 2016 05:53:40 -0500 In-reply-to: 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: julien lepiller Cc: guix-devel@gnu.org > I've been rethinking it, and I would like to use define-configuration > (from cups and dovecot) because it looks really good. But I don't want > to define the same config option for each possible block it can appear > in, and that's why I used (option). So I'm looking for a way to > dynamically define records for each block type, so they can be used more > consistently with what we have. Unfortunately, I don't see how I could > do that, if that is possible at all... Ludo, any idea? I'd like to be > able to write: > > (define-record-type* > ...) > > (define-syntax option > (syntax-rule () > (option mname mtype mdef mdoc mblocks)) > (nginx-option (name mname) (type mtype) ...))) > > (define option-list (list > (option 'server-name server-name 'default "the name of the server that > is served by the http block" (list 'http)) > ...)) > > and then be able to create the block records by filtering that list: > > (define-nginx-configuration nginx-http-block > (filter ... option-list)) > > (define-nginx-configuration nginx-events-block > (filter ... option-list)) > > (define-nginx-configuration nginx-server-block > (filter ... option-list)) > > So the user would then be able to write the service configuration as > they would for any other service we have. What I don't know is how to > write define-nginx-configuration (ideally it would call > define-configuration). With it, I can probably do the rest just fine. Or > maybe there is a better way I don't see yet? I think you are looking for "eval". (define (list->define-configuration stem fields) (eval `(define-configuration ,stem ,@fields) (current-module))) (list->define-configuration 'some-configuration filtered-list) I use it in a service I'm working on (Prosody), to handle virtualhosts.