summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-02-24 14:50:40 +0100
committerRobert Hensing <robert@roberthensing.nl>2022-03-03 00:28:35 +0100
commit81f342d1f3a6bab4a57e195ce99a153b82b1ef86 (patch)
treef66a580998ff47a1fb52e73eb148905cc0df0e43 /lib
parent0c09eb343dfa186c0fbf2bb6cbc36e7a8f369ea5 (diff)
downloadnixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.tar
nixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.tar.gz
nixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.tar.bz2
nixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.tar.lz
nixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.tar.xz
nixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.tar.zst
nixpkgs-81f342d1f3a6bab4a57e195ce99a153b82b1ef86.zip
lib.modules: Explain why options can only be merged into submodules
Diffstat (limited to 'lib')
-rw-r--r--lib/modules.nix9
1 files changed, 9 insertions, 0 deletions
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 "<name>" 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 {