Merge pull request #121875 from Infinisil/small-module-arg-optimization

lib/modules: Small optimization
wip/yesman
Maximilian Bosch 3 years ago committed by GitHub
commit 77b82f3535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      lib/modules.nix

@ -299,13 +299,11 @@ rec {
# a module will resolve strictly the attributes used as argument but # a module will resolve strictly the attributes used as argument but
# not their values. The values are forwarding the result of the # not their values. The values are forwarding the result of the
# evaluation of the option. # evaluation of the option.
requiredArgs = builtins.attrNames (lib.functionArgs f);
context = name: ''while evaluating the module argument `${name}' in "${key}":''; context = name: ''while evaluating the module argument `${name}' in "${key}":'';
extraArgs = builtins.listToAttrs (map (name: { extraArgs = builtins.mapAttrs (name: _:
inherit name; builtins.addErrorContext (context name)
value = builtins.addErrorContext (context name) (args.${name} or config._module.args.${name})
(args.${name} or config._module.args.${name}); ) (lib.functionArgs f);
}) requiredArgs);
# Note: we append in the opposite order such that we can add an error # Note: we append in the opposite order such that we can add an error
# context on the explicited arguments of "args" too. This update # context on the explicited arguments of "args" too. This update

Loading…
Cancel
Save