-
Notifications
You must be signed in to change notification settings - Fork 25
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: explicitly mention pkgs
as module argument
#32
Conversation
The previous change made in PR divnix#31 caused failures when depending on `pkgs` in modules captured by haumea. This is due to the behaviour of `nixpkgs.lib.nixos.evalModules` which does not look up all arguments but only those captured by name explicitly, in addition to `config`, `options`, and `lib` passed by default. This patch fixes those failures by explicitly making `pkgs` part of the argument list for the module returned by `load`, so that `evalModules` applies the correct argument list.
I have tested this with https://github.com/Lord-Valen/configuration.nix, replacing all the FIXMEs. No errors there. |
args: let | ||
args @ {pkgs, ...}: let |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a module system without pkgs
is at least conceivable, so we should preemptively do pkgs ? {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whs-dot-hk what's your thought, here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so, with a default {}
is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't work, because applyModuleArgs
would fail. You cannot specify default arguments for module functions: NixOS/nixpkgs#243303.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't work, because applyModuleArgs
would fail. You cannot specify default arguments for module functions: NixOS/nixpkgs#243303.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Thanks for curating the reference here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, can confirm the default do nothing (such as for pkgs
) with mytest
, when there is no config._module.args.mytest = "test";
there will be an error even a default ""
is given (mytest ? ""
)
I also think transformer with default with haumea.lib.transformers; [
liftDefault
(hoistLists "_imports" "imports")
] would be great if it can pass down from |
Sounds like a good idea. I've seen a few hives which created custom overrides of Perhaps the loader could be treated similarly? Have it default to However, I wouldn't include those changes as part of a quick fix PR. Maybe we include it in the |
Yeah, let's go step by step. Merging... Thx! |
The previous change made in PR #31 caused failures when depending on
pkgs
in modules captured by haumea. This is due to the behaviour ofnixpkgs.lib.nixos.evalModules
which does not look up all arguments but only those captured by name explicitly, in addition toconfig
,options
, andlib
passed by default.This patch fixes those failures by explicitly making
pkgs
part of the argument list for the module returned byload
, so thatevalModules
applies the correct argument list.