mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 03:30:45 +00:00
lib/modules: introduce setDefaultModuleLocation
Wraps a module with a default location for reporting errors.
This commit is contained in:
parent
f90310a12f
commit
5a07097772
|
@ -111,8 +111,8 @@ let
|
|||
cleanSource sourceByRegex sourceFilesBySuffices
|
||||
commitIdFromGitRepo cleanSourceWith pathHasContext
|
||||
canCleanSource pathIsRegularFile pathIsGitRepo;
|
||||
inherit (self.modules) evalModules unifyModuleSyntax
|
||||
applyIfFunction mergeModules
|
||||
inherit (self.modules) evalModules setDefaultModuleLocation
|
||||
unifyModuleSyntax applyIfFunction mergeModules
|
||||
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
||||
pushDownProperties dischargeProperties filterOverrides
|
||||
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
||||
|
|
|
@ -334,6 +334,10 @@ rec {
|
|||
in modulesPath: initialModules: args:
|
||||
filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
|
||||
|
||||
/* Wrap a module with a default location for reporting errors. */
|
||||
setDefaultModuleLocation = file: m:
|
||||
{ _file = file; imports = [ m ]; };
|
||||
|
||||
/* Massage a module into canonical form, that is, a set consisting
|
||||
of ‘options’, ‘config’ and ‘imports’ attributes. */
|
||||
unifyModuleSyntax = file: key: m:
|
||||
|
@ -534,11 +538,9 @@ rec {
|
|||
correspond to the definition of 'loc' in 'opt.file'. */
|
||||
mergeOptionDecls =
|
||||
let
|
||||
packSubmodule = file: m:
|
||||
{ _file = file; imports = [ m ]; };
|
||||
coerceOption = file: opt:
|
||||
if isFunction opt then packSubmodule file opt
|
||||
else packSubmodule file { options = opt; };
|
||||
if isFunction opt then setDefaultModuleLocation file opt
|
||||
else setDefaultModuleLocation file { options = opt; };
|
||||
in loc: opts:
|
||||
foldl' (res: opt:
|
||||
let t = res.type;
|
||||
|
@ -568,7 +570,7 @@ rec {
|
|||
|
||||
getSubModules = opt.options.type.getSubModules or null;
|
||||
submodules =
|
||||
if getSubModules != null then map (packSubmodule opt._file) getSubModules ++ res.options
|
||||
if getSubModules != null then map (setDefaultModuleLocation opt._file) getSubModules ++ res.options
|
||||
else if opt.options ? options then map (coerceOption opt._file) options' ++ res.options
|
||||
else res.options;
|
||||
in opt.options // res //
|
||||
|
|
Loading…
Reference in a new issue