From eb7a17a1cfc158b87e6d349f1fcc550761d122b9 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Fri, 29 Aug 2014 18:52:31 +0200 Subject: [PATCH] Add error an message to prevent use of useless submodules. --- lib/modules.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index bcaadc7fd977..9fe26083cfd4 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -277,13 +277,14 @@ rec { fixupOptionType = loc: opt: let 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: if isFunction x then x else { config, ... }: { options = x; }; options = map coerce (flatten options'); 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 == "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)