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 = "[EMAIL PROTECTED]" squid: cache_mgr = "[EMAIL
> PROTECTED]" ) ?
>
> When using the same names you could do something like this:
>
> services = map (x : x // { adminAddr = "[EMAIL PROTECTED]" }) {
> 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 = "[EMAIL PROTECTED]";
};
services = {
squid = {
adminAddr = "[EMAIL PROTECTED]"; # overrides default
};
# services.httpd.adminAddr not specified, so it defaults
# to [EMAIL PROTECTED]
};
}
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
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev