[Nix-dev] configuring services again - common settings (eg admin email)
Eelco Dolstra
eelco at cs.uu.nl
Wed Nov 28 18:52:17 CET 2007
Marc Weber wrote:
> Some services have the same options such as
> listenToPorts address:port, address:port
> or kind of service admin (eg apache and squid)
>
> Should we strive for keeping the nixos interface simple and looking the
> same for all services or should we try to sue the original names
> (eg apache adminAddr = "admin at h.com" squid: cache_mgr = "admin at h.com" ) ?
>
> When using the same names you could do something like this:
>
> services = map (x : x // { adminAddr = "admin at h.com" }) {
> httpd = ...
> squid = ...
> ...
> }
This doesn't seem very nice because it adds attributes that may not even exist
for certain services (which NixOS doesn't check for now, but we may want to give
an error/warning in the future for undeclared options, e.g. to catch typos).
A better way is to have a system-wide default value for adminAddr, e.g.
system.adminAddr, which the other adminAddr values would default to. Example:
{
system = {
adminAddr = "admin at example.org";
};
services = {
squid = {
adminAddr = "other_admin at example.org"; # overrides default
};
# services.httpd.adminAddr not specified, so it defaults
# to admin at example.org
};
}
Right now this isn't possible because option defaults cannot refer to the actual
values of other options, but that's easy to implement thanks to lazy evaluation
(just pass "config" in system.nix to options.nix).
--
Eelco Dolstra | http://www.cs.uu.nl/~eelco
More information about the nix-dev
mailing list