From 81f342d1f3a6bab4a57e195ce99a153b82b1ef86 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 24 Feb 2022 14:50:40 +0100 Subject: lib.modules: Explain why options can only be merged into submodules --- lib/modules.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/modules.nix b/lib/modules.nix index e6812625f98..62e9615d25b 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -501,6 +501,15 @@ rec { } else if optionDecls != [] then if (lib.head optionDecls).options.type.name == "submodule" + # Raw options can only be merged into submodules. Merging into + # attrsets might be nice, but ambiguous. Suppose we have + # attrset as a `attrsOf submodule`. User declares option + # attrset.foo.bar, this could mean: + # a. option `bar` is only available in `attrset.foo` + # b. option `foo.bar` is available in all `attrset.*` + # c. reject and require "" as a reminder that it behaves like (b). + # d. magically combine (a) and (c). + # All options are merely syntax sugar though. then let opt = fixupOptionType loc (mergeOptionDecls loc (map optionTreeToOption decls)); in { -- cgit 1.4.1