New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #7272 - Allow users to override importsArgs in eval-config.nix. #8932
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.evalModules
argument attribute fromspecialArgs
intoimportsArgs
, to represent the actual use of this argument. Also, this change modify nixoslib/eval-config.nix
to 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
extraArgs
intoimportsArgs
. The difference between the 2 arguments is thatextraArgs
is now evaluated as_module.args
, andimportsArgs
is for arguments which are used for the resolution ofimports
attributes value.cc @edolstra , @shlevy