Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let
elem
filter
foldl'
functionArgs
getAttrFromPath
head
id
Expand Down Expand Up @@ -510,7 +511,7 @@ let
# context on the explicit arguments of "args" too. This update
# operator is used to make the "args@{ ... }: with args.lib;" notation
# works.
in f (args // extraArgs);
in f (builtins.intersectAttrs (functionArgs f) (args // extraArgs));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like performance can improve slightly with this change:

Suggested change
in f (builtins.intersectAttrs (functionArgs f) (args // extraArgs));
in f extraArgs;

(and a rename would be in order)


/* Merge a list of modules. This will recurse over the option
declarations in all modules, combining them into a single set.
Expand Down
3 changes: 3 additions & 0 deletions lib/tests/modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ checkConfigError 'Could not load a value as a module, because it is of type "fla
checkConfigOutput '^true$' "$@" config.enable ./declare-enable.nix ./define-enable-with-top-level-mkIf.nix
checkConfigError 'Could not load a value as a module, because it is of type "configuration", in file .*/import-configuration.nix.*please only import the modules that make up the configuration.*' config ./import-configuration.nix

checkConfigOutput '"foo"' config.foo ./no-ellipsis-module.nix
checkConfigOutput '"foo"' config.foo ./module-with-at-pattern.nix

# doRename works when `warnings` does not exist.
checkConfigOutput '^1234$' config.c.d.e ./doRename-basic.nix
# doRename adds a warning.
Expand Down
5 changes: 5 additions & 0 deletions lib/tests/modules/module-with-at-pattern.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# this no longer works since functionArgs is blind to both `...` and `@`-patterns
{ ... }@inputs: {
options.foo = inputs.lib.mkOption { type = inputs.lib.types.str; };
config.foo = "foo";
}
5 changes: 5 additions & 0 deletions lib/tests/modules/no-ellipsis-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# the module can now request only what it needs without a `...`.
{ lib }: {
options.foo = lib.mkOption { type = lib.types.str; };
config.foo = "foo";
}