summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2021-10-31 19:10:13 +0100
committerRobert Hensing <robert@roberthensing.nl>2021-10-31 22:28:42 +0100
commitd6ebd537e5d212995984152d57e16029b3726de5 (patch)
tree63c2a414d2e2c80a5f3487d8032a35d443036360 /lib/modules.nix
parente544ee88fa4590df75e221e645a03fe157a99e5b (diff)
downloadnixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.tar
nixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.tar.gz
nixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.tar.bz2
nixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.tar.lz
nixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.tar.xz
nixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.tar.zst
nixpkgs-d6ebd537e5d212995984152d57e16029b3726de5.zip
lib/modules: Short-circuit unmatchedDefns when configs is empty
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 46ae3f13631..b2ae51c8e61 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -430,10 +430,16 @@ rec {
 
       # an attrset 'name' => list of unmatched definitions for 'name'
       unmatchedDefnsByName =
-        # Propagate all unmatched definitions from nested option sets
-        mapAttrs (n: v: v.unmatchedDefns) resultsByName
-        # Plus the definitions for the current prefix that don't have a matching option
-        // removeAttrs defnsByName' (attrNames matchedOptions);
+        if configs == []
+        then
+          # When no config values exist, there can be no unmatched config, so
+          # we short circuit and avoid evaluating more _options_ than necessary.
+          {}
+        else
+          # Propagate all unmatched definitions from nested option sets
+          mapAttrs (n: v: v.unmatchedDefns) resultsByName
+          # Plus the definitions for the current prefix that don't have a matching option
+          // removeAttrs defnsByName' (attrNames matchedOptions);
     in {
       inherit matchedOptions;