Skip to content

Commit

Permalink
lib.modules: Inline a private function
Browse files Browse the repository at this point in the history
This should save about four calls per module.
  • Loading branch information
roberth committed Mar 2, 2022
1 parent 28aeae2 commit 2050669
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -566,14 +566,14 @@ rec {
then value: value
else value: { config = value; };

coerce = unify: value: if isFunction value
then setFunctionArgs (args: unify (value args)) (functionArgs value)
else unify (shorthandToModule value);

allModules = defs: imap1 (n: { value, file }:
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
if isFunction value
then setFunctionArgs
(args: lib.modules.unifyModuleSyntax file "${toString file}-${toString n}" (value args))
(functionArgs value)
else if isAttrs value
then
lib.modules.unifyModuleSyntax file "${toString file}-${toString n}" (shorthandToModule value)
else value
) defs;

Expand Down

0 comments on commit 2050669

Please sign in to comment.