Add extraConfigs attribute inside options. This attribute is used to
insert definitions from an external location. As opposed to other defintions, these definitions are always embedded into a list which allow to add multiple definitions with one module. !!! This feature _should not_ be used as a new mean to define options. svn path=/nixpkgs/trunk/; revision=17481
This commit is contained in:
parent
b3b40ebf79
commit
33d43ac18b
@ -230,10 +230,14 @@ rec {
|
|||||||
}"
|
}"
|
||||||
);
|
);
|
||||||
|
|
||||||
config = lib.zipWithNames (modulesNames modules) (name: values:
|
config = lib.zipWithNames (modulesNames modules) (name: values_:
|
||||||
let
|
let
|
||||||
hasOpt = builtins.hasAttr name result.options;
|
hasOpt = builtins.hasAttr name result.options;
|
||||||
opt = lib.getAttr name result.options;
|
opt = lib.getAttr name result.options;
|
||||||
|
values = values_ ++
|
||||||
|
optionals
|
||||||
|
(hasOpt && isOption opt && opt ? extraConfigs)
|
||||||
|
opt.extraConfigs;
|
||||||
|
|
||||||
in if hasOpt && isOption opt then
|
in if hasOpt && isOption opt then
|
||||||
let defs = evalProperties values; in
|
let defs = evalProperties values; in
|
||||||
|
@ -25,6 +25,7 @@ rec {
|
|||||||
# merge (function used to merge definitions into one definition: [ /type/ ] -> /type/)
|
# merge (function used to merge definitions into one definition: [ /type/ ] -> /type/)
|
||||||
# apply (convert the option value to ease the manipulation of the option result)
|
# apply (convert the option value to ease the manipulation of the option result)
|
||||||
# options (set of sub-options declarations & definitions)
|
# options (set of sub-options declarations & definitions)
|
||||||
|
# extraConfigs (list of possible configurations)
|
||||||
};
|
};
|
||||||
|
|
||||||
mapSubOptions = f: opt:
|
mapSubOptions = f: opt:
|
||||||
@ -138,14 +139,17 @@ rec {
|
|||||||
assert opt1 ? merge -> ! opt2 ? merge;
|
assert opt1 ? merge -> ! opt2 ? merge;
|
||||||
assert opt1 ? apply -> ! opt2 ? apply;
|
assert opt1 ? apply -> ! opt2 ? apply;
|
||||||
assert opt1 ? type -> ! opt2 ? type;
|
assert opt1 ? type -> ! opt2 ? type;
|
||||||
if opt1 ? options || opt2 ? options then
|
opt1 // opt2
|
||||||
opt1 // opt2 // {
|
// optionalAttrs (opt1 ? options || opt2 ? options) {
|
||||||
options =
|
options =
|
||||||
(toList (attrByPath ["options"] [] opt1))
|
(toList (attrByPath ["options"] [] opt1))
|
||||||
++ (toList (attrByPath ["options"] [] opt2));
|
++ (toList (attrByPath ["options"] [] opt2));
|
||||||
}
|
}
|
||||||
else
|
// optionalAttrs (opt1 ? extraConfigs || opt2 ? extraConfigs) {
|
||||||
opt1 // opt2
|
extraConfigs =
|
||||||
|
(attrByPath ["extraConfigs"] [] opt1)
|
||||||
|
++ (attrByPath ["extraConfigs"] [] opt2);
|
||||||
|
}
|
||||||
)) {} opts;
|
)) {} opts;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user