I managed to solve this by extending the "top" option definition. So in my "plug-in" module I now have:
{ options.top = mkOption { type = with types; attrsOf (submodule ({ name, config, ... }: { config.opt2 = f name; }; }; } / Rickard On 07/01/2015 12:31 AM, Rickard Nilsson wrote: > Hi, > > I'm stuck on the following problem with the NixOS module system: > > Say I have an option definition like this: > > let > subOpts = { ... }: { > options = { > opt1 = mkOption { ... }; > opt2 = mkOption { ... }; > }; > }; > > in { > options = { > top = mkOption { > type = with types; attrsOf (submodule subOpts); > default = {}; > }; > }; > } > > Then I use it like this: > > top = { > one.opt1 = ...; > two.opt1 = ...; > }; > > And now I want to set top.*.opt2 in a separate module, based on the > existing attributes. Essentially something like this: > > top = mkMerge ( > map (a: { ${a}.opt2 = f a; }) (attrNames config.top) > ) > > But of course, the above results in an infinite recursion since I'm > using config.top in its own definition. > > What I want is simply to be able to plug in a module that defines some > sub-options without having explicit knowledge about the attribute set. > > Does anyone know a way of achieveing this? > > > / Rickard > _______________________________________________ > nix-dev mailing list > nix-dev@lists.science.uu.nl > http://lists.science.uu.nl/mailman/listinfo/nix-dev > _______________________________________________ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev