all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: julien lepiller <julien@lepiller.eu>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] improve nginx-service
Date: Sun, 27 Nov 2016 22:01:47 +0100	[thread overview]
Message-ID: <87r35wljr8.fsf@gnu.org> (raw)
In-Reply-To: <b8ab2d264e32fe097196722b346f1c25@lepiller.eu> (julien lepiller's message of "Wed, 23 Nov 2016 10:26:23 +0100")

Hi, and sorry for the delay!

julien lepiller <julien@lepiller.eu> skribis:

> Le 2016-11-22 23:20, Hartmut Goebel a écrit :
>> Am 20.11.2016 um 13:49 schrieb Julien Lepiller:
>>> What do you think? should I continue in that direction, or should I go
>>> back to what I was doing before?
>>
>> Thanks for working on this. I will give it a try the next days. But I
>> want to share two points going around in my head:
>>
>> 1) I propose moving the nginx service into a package
>> gnu/service/nginx.scm. Imagine we will implement an equal complex
>> config
>> schema for apache. Then we will get a beast of code with lots of
>> useless
>> "nginx-" prefixes.
>>
>> 2) Is it possible to add some magic to e.g. "nginx-service-type" so
>> that
>> all identifiers within are searched in the "nginx" scope. Example:
>>
>>       (service-extension
>>         nginx-service-type
>>          (const (list (server    ;; taken from "nginx" scope
>>                         (blocks (list))
>>                         (configs (list
>>                                   (option (type 'server_name)     ;;
>> taken from "nginx" scope
>>                                           (value (list 'default)))
>
> I am quite new to scheme, but as far as I can tell, there is no notion
> of scope. Here, (option ...) can be independent from nginx or apache
> (because there is nothing specific), but probably not (server),
> because it is a notion specific to nginx and because what it can
> contain is different in the apache world and nginx world. Also, how
> would the two types be recognized when you want both apache and nginx
> (probably not useful, but it may happen)?
>
> 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* <nginx-option>
>   ...)
>
> (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’ve played a bit with nginx and I think its configuration syntax is far
from trivial.  Services for Dovecot, Kerberos, glibc’s name service
switch, PAM, etc. are pretty clear: it’s quite easy to find out what
data structures the config defines, and to write Scheme bindings for
those structures.

In the case of nginx, it’s much more complex: there’s a notion of scope
and inheritance (some key/value pairs are inherited from the “parent”
context), there are conditionals, variables, keys associated with more
than one value, etc.  Tricky.

So there are two ways to approach it:

  1. Choose a small subset of the functionality, like you’ve done with
     vhosts, and provide bindings for that subset.  It’ll be less
     expressive than nginx’s config files (so users need a way to
     provide nginx-language config when needed), but it can still be
     useful.  And it’s not too hard to implement.

  2. Write bindings for the whole configuration language, such that
     there is no loss of expressivity.  This is the grail, but obviously
     it requires a very good understanding of that language, and it’s
     going to be much more work.

I think it would make sense to stick to #1 in the short- to medium term.
But if you’re an nginx wizard, you might find that #2 is piece of cake;
you’ll have to decide!  :-)

Back to the original comment about “vhost”, I think we could simply
replace “vhost” with “server” in the code, since those
<nginx-vhost-configuration> objects map to ‘server’ blocks.

WDYT?

Thanks,
Ludo’.

  parent reply	other threads:[~2016-11-27 21:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-16 12:33 [PATCH] improve nginx-service Julien Lepiller
2016-10-19 21:04 ` Ludovic Courtès
2016-10-20 12:37   ` Julien Lepiller
2016-10-24 20:51     ` Ludovic Courtès
2016-10-26 19:45       ` Julien Lepiller
2016-10-27 12:41         ` Ludovic Courtès
2016-10-27 17:59           ` Julien Lepiller
2016-10-30 21:46             ` Ludovic Courtès
2016-11-02  8:22               ` Hartmut Goebel
2016-11-03 14:54                 ` Ludovic Courtès
2016-11-03 22:38                   ` Hartmut Goebel
2016-11-04 13:21                     ` Ludovic Courtès
2016-11-04 18:01                       ` Julien Lepiller
2016-11-04 21:28                         ` Hartmut Goebel
2016-11-04 22:12                           ` Julien Lepiller
2016-11-04 22:34                             ` Hartmut Goebel
2016-11-06 11:11                               ` Julien Lepiller
2016-11-04 22:58                             ` Hartmut Goebel
2016-11-06 12:18                               ` Tobias Geerinckx-Rice
2016-11-06 17:19                                 ` Ludovic Courtès
2016-11-20 12:49                                   ` Julien Lepiller
2016-11-22 22:20                                     ` Hartmut Goebel
2016-11-23  9:26                                       ` julien lepiller
2016-11-25 10:53                                         ` Clément Lassieur
2016-11-25 11:46                                           ` is using eval good style in guile?(was: [PATCH] improve nginx-service) Hartmut Goebel
2016-11-25 13:29                                             ` is using eval good style in guile? Andy Wingo
2016-11-26 21:55                                               ` Clément Lassieur
2016-11-27 21:01                                         ` Ludovic Courtès [this message]
2016-11-06 17:33                               ` [PATCH] improve nginx-service Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r35wljr8.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=julien@lepiller.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.