summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2020-01-12 14:19:04 +0100
committerGitHub <noreply@github.com>2020-01-12 14:19:04 +0100
commit9884cb3ed004984696a64915849afe175ac5c597 (patch)
tree6a6b40e2d3abaa9d552f6d3fdffebd07f3bfbeb4 /lib
parenta23a985594bf7c3eb543bdaf1e7a9c5b6ddd6099 (diff)
parent9d4b59b54949f0849ab9db9d30bc4cce7a205787 (diff)
downloadnixpkgs-9884cb3ed004984696a64915849afe175ac5c597.tar
nixpkgs-9884cb3ed004984696a64915849afe175ac5c597.tar.gz
nixpkgs-9884cb3ed004984696a64915849afe175ac5c597.tar.bz2
nixpkgs-9884cb3ed004984696a64915849afe175ac5c597.tar.lz
nixpkgs-9884cb3ed004984696a64915849afe175ac5c597.tar.xz
nixpkgs-9884cb3ed004984696a64915849afe175ac5c597.tar.zst
nixpkgs-9884cb3ed004984696a64915849afe175ac5c597.zip
Merge pull request #76861 from Infinisil/paths-as-submodules
lib/types: Allow paths as submodule values
Diffstat (limited to 'lib')
-rwxr-xr-xlib/tests/modules.sh3
-rw-r--r--lib/types.nix8
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index c8340ff7f15..8cd632a439c 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -174,8 +174,7 @@ checkConfigOutput "true" config.submodule.inner ./declare-submoduleWith-modules.
 checkConfigOutput "true" config.submodule.outer ./declare-submoduleWith-modules.nix
 
 ## Paths should be allowed as values and work as expected
-# Temporarily disabled until https://github.com/NixOS/nixpkgs/pull/76861
-#checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix
+checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix
 
 # Check that disabledModules works recursively and correctly
 checkConfigOutput "true" config.enable ./disable-recursive/main.nix
diff --git a/lib/types.nix b/lib/types.nix
index e86f6d36476..e6f84176657 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -430,14 +430,16 @@ rec {
           else unify (if shorthandOnlyDefinesConfig then { config = value; } else value);
 
         allModules = defs: modules ++ imap1 (n: { value, file }:
-          # Annotate the value with the location of its definition for better error messages
-          coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
+          if isAttrs value || isFunction value then
+            # Annotate the value with the location of its definition for better error messages
+            coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
+          else value
         ) defs;
 
       in
       mkOptionType rec {
         name = "submodule";
-        check = x: isAttrs x || isFunction x;
+        check = x: isAttrs x || isFunction x || path.check x;
         merge = loc: defs:
           (evalModules {
             modules = allModules defs;