summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2021-11-03 19:05:26 +0100
committerRobert Hensing <robert@roberthensing.nl>2021-11-03 19:05:26 +0100
commitbfaa9426c0e70b387f58bce6248b454b556018c2 (patch)
treee1e35f4cda758cdfccb9c4ff17dfbea36c9318f5 /lib
parentd6ebd537e5d212995984152d57e16029b3726de5 (diff)
lib/modules: Short-circuit unmatchedDefns earlier
Diffstat (limited to 'lib')
-rw-r--r--lib/modules.nix31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index b2ae51c8e618..4bbf2947bc4e 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -430,26 +430,27 @@ 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);
+ in {
+ inherit matchedOptions;
+
+ # Transforms unmatchedDefnsByName into a list of definitions
+ unmatchedDefns =
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;
-
- # Transforms unmatchedDefnsByName into a list of definitions
- unmatchedDefns = concatLists (mapAttrsToList (name: defs:
- map (def: def // {
- # Set this so we know when the definition first left unmatched territory
- prefix = [name] ++ (def.prefix or []);
- }) defs
- ) unmatchedDefnsByName);
+ concatLists (mapAttrsToList (name: defs:
+ map (def: def // {
+ # Set this so we know when the definition first left unmatched territory
+ prefix = [name] ++ (def.prefix or []);
+ }) defs
+ ) unmatchedDefnsByName);
};
/* Merge multiple option declarations into a single declaration. In