summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2023-07-27 10:55:08 +0200
committerGitHub <noreply@github.com>2023-07-27 10:55:08 +0200
commit19f1d7da06cb4553a05cd1759b667bc7adf405fa (patch)
tree38487ae5fd4a3b112ca332edb0e99edc96aa7b16
parentf705094eac9feaafa7c35ad525fe454d4fabc5c8 (diff)
parent9c35f44999b38f07b674ff25cde17452ab4a1969 (diff)
downloadnixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.tar
nixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.tar.gz
nixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.tar.bz2
nixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.tar.lz
nixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.tar.xz
nixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.tar.zst
nixpkgs-19f1d7da06cb4553a05cd1759b667bc7adf405fa.zip
Merge pull request #245271 from sternenseemann/module-system-merge-no-type
lib/modules: handle typeless options in mergeModules
-rw-r--r--lib/modules.nix2
-rwxr-xr-xlib/tests/modules.sh3
-rw-r--r--lib/tests/modules/merge-typeless-option.nix25
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index f16df20425e..4966619f663 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -639,7 +639,7 @@ let
               unmatchedDefns = [];
             }
           else if optionDecls != [] then
-              if all (x: x.options.type.name == "submodule") optionDecls
+              if all (x: x.options.type.name or null == "submodule") optionDecls
               # 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
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index 180cca9955e..4adbd69effb 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -371,6 +371,9 @@ checkConfigError \
   config.set \
   ./declare-set.nix ./declare-enable-nested.nix
 
+# Check that that merging of option collisions doesn't depend on type being set
+checkConfigError 'The option .group..*would be a parent of the following options, but its type .<no description>. does not support nested options.\n\s*- option.s. with prefix .group.enable..*' config.group.enable ./merge-typeless-option.nix
+
 # Test that types.optionType merges types correctly
 checkConfigOutput '^10$' config.theOption.int ./optionTypeMerging.nix
 checkConfigOutput '^"hello"$' config.theOption.str ./optionTypeMerging.nix
diff --git a/lib/tests/modules/merge-typeless-option.nix b/lib/tests/modules/merge-typeless-option.nix
new file mode 100644
index 00000000000..627d90b15db
--- /dev/null
+++ b/lib/tests/modules/merge-typeless-option.nix
@@ -0,0 +1,25 @@
+{ lib, ... }:
+
+let
+  typeless =
+    { lib, ... }:
+
+    {
+      options.group = lib.mkOption { };
+    };
+  childOfTypeless =
+    { lib, ... }:
+
+    {
+      options.group.enable = lib.mkEnableOption "nothing";
+    };
+in
+
+{
+  imports = [
+    typeless
+    childOfTypeless
+  ];
+
+  config.group.enable = false;
+}