From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] improve nginx-service Date: Sun, 30 Oct 2016 22:46:15 +0100 Message-ID: <87pomhse6w.fsf@gnu.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> 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]:58174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0xvr-0005x8-Im for guix-devel@gnu.org; Sun, 30 Oct 2016 17:46:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0xvm-0003hM-P0 for guix-devel@gnu.org; Sun, 30 Oct 2016 17:46:23 -0400 In-Reply-To: <20161027195949.354cae8e@lepiller.eu> (Julien Lepiller's message of "Thu, 27 Oct 2016 19:59:49 +0200") 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 Julien Lepiller skribis: > On Thu, 27 Oct 2016 14:41:18 +0200 > ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > >> [...] >> >> What I had in mind was just to add =E2=80=98compose=E2=80=99 and =E2=80= =98extend=E2=80=99 to >> =E2=80=98nginx-service-type=E2=80=99 (this is where we define how extens= ions are >> handled). There=E2=80=99s a bit of extra bookeeping to do, in particular >> moving the list of vhosts to , as in this >> untested patch: >>=20 [...] > Actually your patch didn't help me except for syntax simplification. > Your answer was not really helpful, Fair enough. :-) > but it forced me to consider what I really wanted. So my use case > would be that I would like to run a webservice from the store (all > configuration should be made via guix). But my problem is that I > don't know how to get the path to the store that I could pass as the > root parameter in nginx-vhost-config. OK, that doesn=E2=80=99t have much to do with making nginx-service-type extensible. But we can do both! If the vhost=E2=80=99s root directory is immutable, you can of course add i= t to the store via =E2=80=98computed-file=E2=80=99 or similar, and then write: (nginx-vhost-configuration (root #$(computed-file "root" =E2=80=A6))) If it=E2=80=99s mutable, as is often going to be the case, you can simply p= ass its file name: (nginx-vhost-configuration (root "/var/www/the-service")) In that case, it=E2=80=99s up to you to make sure that /var/www/the-service exists and contains the right thing. Does that answer your question? > Also, I don't know what the best solution would be to get a configured > web service in the store. Configuration is usually in a file in the > root directory, and sometimes a default file is already present and you > are supposed to modify it by hand. The issue here is that the store is > read-only. How could you create a configuration file that can be found > in the package's directory (using a guix service)? Would that mean that > I have to copy the whole package and change just one file? Is there > anything better, or do I have no other choice than install it outside of > guix? All the daemons (almost all of them) started on GuixSD get their config file from the store. When you wrote: #~(system* #$(file-append nginx "/bin/nginx") "-c" #$config-file) that translated to: (system* "/gnu/store/=E2=80=A6/bin/nginx" "-c" "/gnu/store/=E2=80=A6-conf= ig") where /gnu/store/=E2=80=A6-config is a file that was generated using =E2=80=98computed-file=E2=80=99 or similar. I think the same approach should work for a Web service, but without being more specific I can=E2=80=99t tell. > From 25a296057969a35b86ea7371577504c43bf96334 Mon Sep 17 00:00:00 2001 > From: Julien Lepiller > Date: Thu, 27 Oct 2016 19:47:27 +0200 > Subject: [PATCH] service: Make nginx-service extensible > > gnu/services/web.scm (nginx-service-type): Make extensible [...] > +@deffn [Scheme Variable] nginx-service-type ^ Should be braces. > +This is the type for the @code{nginx} web server. =E2=80=9Cnginx=E2=80=9D (the proper name, not the command name.) > (nginx nginx-configuration-nginx) ; > (log-directory nginx-configuration-log-directory) ;string > (run-directory nginx-configuration-run-directory) ;string > + (vhosts nginx-configuration-vhosts) ;list of Please add a default value like at . I hindsight, I wonder why I put that one-element list as the default; shouldn=E2=80=99t it be the empty list? > (file nginx-configuration-file)) ;string | file-like >=20=20 > (define (config-domain-strings names) > @@ -102,11 +104,13 @@ of index files." > " server_name " (config-domain-strings > (nginx-vhost-configuration-server-name vhost)) > ";\n" > - (if (nginx-vhost-configuration-ssl-certificate vhost) > + (if (and (nginx-vhost-configuration-https-port vhost) > + (nginx-vhost-configuration-ssl-certificate vhost)) > (string-append " ssl_certificate " > (nginx-vhost-configuration-ssl-certificate vhost) = ";\n") > "") > - (if (nginx-vhost-configuration-ssl-certificate-key vhost) > + (if (and (nginx-vhost-configuration-https-port vhost) > + (nginx-vhost-configuration-ssl-certificate-key vhost)) Could you remove these changes? I think they are unrelated. > (define* (nginx-service #:key (nginx nginx) > (log-directory "/var/log/nginx") > (run-directory "/var/run/nginx") > - (vhost-list (list (nginx-vhost-configuration))) > - (config-file > - (default-nginx-config log-directory run-directo= ry vhost-list))) > + (vhost-list (list (nginx-vhost-configuration > + (https-port #f)))) Please remove the =E2=80=98https-port=E2=80=99 setting. Apart from that it LGTM. Could you send an updated patch? Thanks! Ludo=E2=80=99.