Fix #7272 - Allow users to override importsArgs in eval-config.nix.#8932
Fix #7272 - Allow users to override importsArgs in eval-config.nix.#8932nbp wants to merge 1 commit intoNixOS:masterfrom
Conversation
|
Could you tell me how this fixes #7272? I've tried applying your commit and then evaluating the following configuration: { config, pkgs, lib, hydra_path, ... }:
{
_module.importsArgs.hydra_path = lib.mkDefault "/root/src/localrepos/hydra";
imports = [
"${hydra_path}/hydra-module.nix"
];
}... but this fails with: When trying the old way: { config, pkgs, lib
, hydra_path ? "/root/src/localrepos/hydra"
, ... }:
{
imports = [
"${hydra_path}/hydra-module.nix"
];
}... it also fails with infinite recursion. What am I doing wrong? |
|
Basically, this would work the same way as you described in #7272 (comment) , except that instead of having an argument named Also, I recall @edolstra mentioning that hydra updates NIX_PATH environment variable with the path of the project inputs, such that you should be able to use <hydra_path> in your import statements. If this alternative works for you, this would avoid landing the current fix. |
|
Right, I understand how the The point of having the default values was so that I could directly evaluate (e.g.) |
|
@nbp what's the status of this? |
|
@wizeman , I suggested an alternative in #7272 (comment) which I think might work for your use case, if you were to separate the module arguments from the paths arguments. @domenkozar Thanks for pinging. |
|
Note, #11106 should solve this problem without the need of adding extra arguments to modules, by importing the configuration with This module will basically re-evaluate NixOS with the additional extra modules as-if they were dynamic-imports. |
|
Closing as this issue is solved by #11106. |
These changes renames the
lib.evalModulesargument attribute fromspecialArgsintoimportsArgs, to represent the actual use of this argument. Also, this change modify nixoslib/eval-config.nixto expose this argument and to use it to override the default set of arguments defined in this file.This would solve the issue #7272, by renaming
extraArgsintoimportsArgs. The difference between the 2 arguments is thatextraArgsis now evaluated as_module.args, andimportsArgsis for arguments which are used for the resolution ofimportsattributes value.cc @edolstra , @shlevy