lib/modules: provide error message when imports contains a list

This commit is contained in:
Nicolas Berbiche 2021-03-03 00:59:52 -05:00
parent 2149ad5bdf
commit 810c9c6a0e
No known key found for this signature in database
GPG key ID: FA5696EDF35DA0B6

View file

@ -23,6 +23,7 @@ let
isAttrs isAttrs
isBool isBool
isFunction isFunction
isList
isString isString
length length
mapAttrs mapAttrs
@ -188,6 +189,9 @@ rec {
loadModule = args: fallbackFile: fallbackKey: m: loadModule = args: fallbackFile: fallbackKey: m:
if isFunction m || isAttrs m then if isFunction m || isAttrs m then
unifyModuleSyntax fallbackFile fallbackKey (applyIfFunction fallbackKey m args) unifyModuleSyntax fallbackFile fallbackKey (applyIfFunction fallbackKey m args)
else if isList m then
let defs = [{ file = fallbackFile; value = m; }]; in
throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
else unifyModuleSyntax (toString m) (toString m) (applyIfFunction (toString m) (import m) args); else unifyModuleSyntax (toString m) (toString m) (applyIfFunction (toString m) (import m) args);
/* /*