[Nix-dev] NixOS: Apache-httpd sub-services.
Nicolas Pierron
nicolas.b.pierron at gmail.com
Fri Nov 6 14:06:00 CET 2009
Hi Nixers,
Summary:
Modifications:
- Remove main host definition / declarations from services.httpd and
move it inside services.httpd.hosts.
- Remove unamed virtual hosts defined in services.httpd.virtualHosts
and replace them by named virtual hosts in services.httpd.hosts.
- Define the main host by ""pointing"" one among the list of hosts.
Pros:
- Remove duplicated documentation from the manual.
- Clean-up httpd sub-services syntax.
- Allow hosts extensions.
Cons:
- Implies that all httpd-NixOS user will have to update their configuration.
- Force to have unique name for each virtual hosts.
I am on my way to add documentation on httpd-host sub-services. To
add such documentation will have many impacts. First people watching
the NixOS manual will be aware that they can easily setup a Trac /
Subversion / ... services in just a few configuration options and this
will reduce many question on how to setup such systems.
Unfortunately I've encounter one huge problem that and that I would
like to get rid of. Currently httpd can have both a main server
configuration in addition to virtual hosts. This small thing add too
much complexity when you want to write a module, you get something
like:
{
options = {
services.httpd = {
virtualHosts = mkOption {
options = [ serviceModule ];
};
} // (serviceModule mainServerArgs).options;
}
config = {
services.httpd = (serviceModule mainServerArgs).config;
};
}
The nicest solution here is what I've succeed to achieved inside the
virtualHosts option. The virtualHosts options is a list of
sub-modules (which are modules) which allow you to add sub-services
into sub-modules with:
{
options.services.httpd.virtualHosts =mkOption {
options = [ serviceModule ];
};
}
Such solution would be enough but it neither handles host extensions
nor distinction of the main host. What I suggest is to write a new
"hosts" options in which you will add attributes which are
representing each of your hosts. Then you can set your main server by
defining and option inside services.httpd, like:
# configuration.nix and others
{
services.httpd.mainHost = "web"; # or config.services.httpd.hosts.web
services.httpd.hosts = {
wiki = { ... };
svn = { ... };
web = { ... };
};
}
The main Host option is just an attribute set in which you define
which host is the primary host among the hosts which are listed inside
"services.httpd.hosts". Other hosts inside "services.httpd.hosts" are
virtual hosts and would inherit properties like "adminAddr" from the
main host (as the current implementation do). Moreover this
implementation will remove duplicated documentation from the manual
and allow you to extend web servers from an other location in addition
to named then in other services which are relying on specific hosts
configurations.
I don't know if there is any difference between one main host and no
main host and one virtual host, but if there isn't, then we can
automatically set the main host if there is only one host declared.
--
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
Albert Einstein - Never memorize what you can look up on books.
More information about the nix-dev
mailing list