diff options
author | Robert Hensing <robert@roberthensing.nl> | 2021-11-03 19:05:26 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2021-11-03 19:05:26 +0100 |
commit | bfaa9426c0e70b387f58bce6248b454b556018c2 (patch) | |
tree | e1e35f4cda758cdfccb9c4ff17dfbea36c9318f5 /lib | |
parent | d6ebd537e5d212995984152d57e16029b3726de5 (diff) | |
download | nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.tar nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.tar.gz nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.tar.bz2 nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.tar.lz nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.tar.xz nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.tar.zst nixpkgs-bfaa9426c0e70b387f58bce6248b454b556018c2.zip |
lib/modules: Short-circuit unmatchedDefns earlier
Diffstat (limited to 'lib')
-rw-r--r-- | lib/modules.nix | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index b2ae51c8e61..4bbf2947bc4 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 |