Add location to declared sub-modules.
svn path=/nixpkgs/trunk/; revision=17252
This commit is contained in:
parent
a727aa8d8b
commit
e07f5d2a2c
|
@ -54,9 +54,10 @@ rec {
|
|||
removeAttrs (delayProperties m) ["require"];
|
||||
in
|
||||
if isModule m then
|
||||
m
|
||||
{ key = "<unknow location>"; } // m
|
||||
else
|
||||
{
|
||||
key = "<unknow location>";
|
||||
imports = getImportedPaths m;
|
||||
config = getConfig m;
|
||||
} // (
|
||||
|
@ -72,8 +73,7 @@ rec {
|
|||
moduleImport = m:
|
||||
(unifyModuleSyntax (applyIfFunction (importIfPath m) args)) // {
|
||||
# used by generic closure to avoid duplicated imports.
|
||||
key = if isPath m then m else
|
||||
/bad/developer/implies/bad/error/messages;
|
||||
key = if isPath m then m else "<unknow location>";
|
||||
};
|
||||
|
||||
getImports = m: attrByPath ["imports"] [] m;
|
||||
|
@ -188,9 +188,25 @@ rec {
|
|||
moduleZip {
|
||||
options = lib.zip (name: values:
|
||||
if any isOption values then
|
||||
addOptionMakeUp
|
||||
{ name = addName name; recurseInto = recurseForOption; }
|
||||
(mergeOptionDecls values)
|
||||
let
|
||||
# locations to sub-options declarations
|
||||
decls =
|
||||
map (m:
|
||||
mapSubOptions (subModule:
|
||||
let module = lib.applyIfFunction subModule {}; in
|
||||
if lib.isModule module then
|
||||
{ inherit (m) key; } // subModule
|
||||
else
|
||||
args: {
|
||||
inherit (m) key;
|
||||
options = lib.applyIfFunction subModule args;
|
||||
}
|
||||
) m.options
|
||||
) (declarationsOf name);
|
||||
in
|
||||
addOptionMakeUp
|
||||
{ name = addName name; recurseInto = recurseForOption; }
|
||||
(mergeOptionDecls decls)
|
||||
else if all isAttrs values then
|
||||
(recurseInto name modules).options
|
||||
else
|
||||
|
|
|
@ -27,6 +27,14 @@ rec {
|
|||
# options (set of sub-options declarations & definitions)
|
||||
};
|
||||
|
||||
mapSubOptions = f: opt:
|
||||
if opt ? options then
|
||||
opt // {
|
||||
options = map f (toList opt.options);
|
||||
}
|
||||
else
|
||||
opt;
|
||||
|
||||
# Make the option declaration more user-friendly by adding default
|
||||
# settings and some verifications based on the declaration content (like
|
||||
# type correctness).
|
||||
|
@ -68,20 +76,6 @@ rec {
|
|||
}
|
||||
else opt;
|
||||
|
||||
convertOptionsToModules = opt:
|
||||
if opt ? options then
|
||||
opt // {
|
||||
options = map (decl:
|
||||
let module = lib.applyIfFunction decl {}; in
|
||||
if lib.isModule module then
|
||||
decl
|
||||
else
|
||||
arg: { options = lib.applyIfFunction decl arg; }
|
||||
) opt.options;
|
||||
}
|
||||
else
|
||||
opt;
|
||||
|
||||
handleOptionSets = opt:
|
||||
if decl ? type && decl.type.hasOptions then
|
||||
let
|
||||
|
@ -119,7 +113,6 @@ rec {
|
|||
# override settings
|
||||
ensureMergeInputType
|
||||
ensureDefaultType
|
||||
convertOptionsToModules
|
||||
handleOptionSets
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue