Add error an message to prevent use of useless submodules.

This commit is contained in:
Nicolas Pierron 2014-08-29 18:52:31 +02:00
parent 8c19690d99
commit eb7a17a1cf

View File

@ -277,13 +277,14 @@ rec {
fixupOptionType = loc: opt: fixupOptionType = loc: opt:
let let
options' = opt.options or options' = opt.options or
(throw "Option `${showOption loc'}' has type optionSet but has no option attribute."); (throw "Option `${showOption loc'}' has type optionSet but has no option attribute, in ${showFiles opt.declarations}.");
coerce = x: coerce = x:
if isFunction x then x if isFunction x then x
else { config, ... }: { options = x; }; else { config, ... }: { options = x; };
options = map coerce (flatten options'); options = map coerce (flatten options');
f = tp: f = tp:
if tp.name == "option set" then types.submodule options if tp.name == "option set" || tp.name == "submodule" then
throw "The option ${showOption loc} uses submodules without a wrapping type, in ${showFiles opt.declarations}."
else if tp.name == "attribute set of option sets" then types.attrsOf (types.submodule options) else if tp.name == "attribute set of option sets" then types.attrsOf (types.submodule options)
else if tp.name == "list or attribute set of option sets" then types.loaOf (types.submodule options) else if tp.name == "list or attribute set of option sets" then types.loaOf (types.submodule options)
else if tp.name == "list of option sets" then types.listOf (types.submodule options) else if tp.name == "list of option sets" then types.listOf (types.submodule options)