* Add "_args" to all sub-module configurations result. This attribute
enable argument introspection outside of the scope of each sub-module. svn path=/nixpkgs/trunk/; revision=18240
This commit is contained in:
parent
10d74af2f6
commit
233d72e4fb
|
@ -83,26 +83,35 @@ rec {
|
||||||
if opt ? type && opt.type.hasOptions then
|
if opt ? type && opt.type.hasOptions then
|
||||||
let
|
let
|
||||||
|
|
||||||
optionConfig = vals: path: config:
|
optionConfig = vals: args:
|
||||||
let name = lib.removePrefix (opt.name + ".") path; in
|
map (f: lib.applyIfFunction f args)
|
||||||
map (f: lib.applyIfFunction f ({inherit name;} // config))
|
|
||||||
(opt.options ++ toList vals);
|
(opt.options ++ toList vals);
|
||||||
|
|
||||||
|
# Evaluate sub-modules.
|
||||||
|
subModuleMerge = path: vals:
|
||||||
|
lib.fix (args:
|
||||||
|
let result = recurseInto path (optionConfig vals args); in {
|
||||||
|
inherit (result) config options;
|
||||||
|
name = lib.removePrefix (opt.name + ".") path;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# Add _options in sub-modules to make it viewable from other
|
||||||
|
# modules.
|
||||||
|
subModuleMergeConfig = path: vals:
|
||||||
|
let result = subModuleMerge path vals; in
|
||||||
|
{ _args = result; } // result.config;
|
||||||
|
|
||||||
in
|
in
|
||||||
opt // {
|
opt // {
|
||||||
merge = list:
|
merge = list:
|
||||||
opt.type.iter
|
opt.type.iter
|
||||||
(path: vals:
|
subModuleMergeConfig
|
||||||
(lib.fix
|
|
||||||
(fixableMergeFun (recurseInto path) (optionConfig vals path))
|
|
||||||
).config
|
|
||||||
)
|
|
||||||
opt.name
|
opt.name
|
||||||
(opt.merge list);
|
(opt.merge list);
|
||||||
options =
|
options =
|
||||||
let path = opt.type.docPath opt.name; in
|
let path = opt.type.docPath opt.name; in
|
||||||
(lib.fix
|
(subModuleMerge path []).options;
|
||||||
(fixableMergeFun (recurseInto path) (optionConfig [] path))
|
|
||||||
).options;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
opt;
|
opt;
|
||||||
|
|
Loading…
Reference in New Issue