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?