mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
lib.modules: Add hint when using config in imports
This commit is contained in:
@@ -637,6 +637,15 @@ let
|
||||
key: f:
|
||||
args@{ config, ... }:
|
||||
let
|
||||
importHint =
|
||||
name:
|
||||
if name == "config" then
|
||||
"\n\n"
|
||||
+ ''
|
||||
… If you get an infinite recursion here, you probably reference `config`
|
||||
in `imports`. This is not supported; consider using mkEnableOption.''
|
||||
else
|
||||
"";
|
||||
# Module arguments are resolved in a strict manner when attribute set
|
||||
# deconstruction is used. As the arguments are now defined with the
|
||||
# config._module.args option, the strictness used on the attribute
|
||||
@@ -649,7 +658,7 @@ let
|
||||
# a module will resolve strictly the attributes used as argument but
|
||||
# not their values. The values are forwarding the result of the
|
||||
# evaluation of the option.
|
||||
context = name: ''while evaluating the module argument `${name}' in "${key}":'';
|
||||
context = name: ''while evaluating the module argument `${name}' in "${key}":${importHint name}'';
|
||||
extraArgs = mapAttrs (
|
||||
name: _: addErrorContext (context name) (args.${name} or config._module.args.${name})
|
||||
) (functionArgs f);
|
||||
|
||||
Reference in New Issue
Block a user