[Nix-dev] nixos modules: Setting attrsOf sub-options
Nicolas Pierron
nicolas.b.pierron at gmail.com
Sun Jul 5 23:47:40 CEST 2015
Hi,
On Wed, Jul 1, 2015 at 12:31 AM, Rickard Nilsson
<rickard.nilsson at telia.com> wrote:
> top = mkMerge (
> map (a: { ${a}.opt2 = f a; }) (attrNames config.top)
> )
This would work, only if you were not redefining top, or if you knew
the list of names ahead.
> {
> options.top = mkOption {
> type = with types; attrsOf (submodule ({ name, config, ... }: {
> config.opt2 = f name;
> };
> };
> }
On the other hand, this is the proper way to extend submodules.
Note that `opt1` can be accessed with `config.opt1` within each submodule.
--
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
More information about the nix-dev
mailing list