From bbb4ce1dd77d7a4b056d2ee3c5029c883cf28070 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Tue, 6 Oct 2009 09:21:46 +0000 Subject: [PATCH] Extract the path done inside the iteration process of the option type and give it as argument to each sub-module. With the type "types.attrsOf types.optionSet", you will obtain the name of the attribute in which the sub-modules are contained. svn path=/nixpkgs/trunk/; revision=17669 --- pkgs/lib/options.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix index 6f1b1afe12a..b7797cabbb4 100644 --- a/pkgs/lib/options.nix +++ b/pkgs/lib/options.nix @@ -83,16 +83,17 @@ rec { if opt ? type && opt.type.hasOptions then let - optionConfig = opts: config: - map (f: lib.applyIfFunction f config) - (opt.options ++ toList opts); + optionConfig = vals: path: config: + let name = lib.removePrefix (opt.name + ".") path; in + map (f: lib.applyIfFunction f ({inherit name;} // config)) + (opt.options ++ toList vals); in opt // { merge = list: opt.type.iter - (path: opts: + (path: vals: (lib.fix - (fixableMergeFun (recurseInto path) (optionConfig opts)) + (fixableMergeFun (recurseInto path) (optionConfig vals path)) ).config ) opt.name @@ -100,7 +101,7 @@ rec { options = let path = opt.type.docPath opt.name; in (lib.fix - (fixableMergeFun (recurseInto path) (optionConfig [])) + (fixableMergeFun (recurseInto path) (optionConfig [] path)) ).options; } else