nix-community / flakelight

Framework for simplifying flake setup [maintainer=@accelbread]
MIT License
227 stars 5 forks source link

Ensure module args is set for modules #25

Closed ratson closed 2 weeks ago

ratson commented 3 weeks ago

Fix https://github.com/nix-community/flakelight/issues/22

Run test.sh in https://github.com/ratson/bug-report/tree/flakelight-nixos-module-fixed verified the problem solved.

accelbread commented 2 weeks ago

Hmm, I'm not sure doing this by default is a good idea, as it conflates arguments from where the module is defined vs arguments where it is defined. With this, all of the defining flakes's module args are made available to exported modules which may not be desirable. It would mean that adding an arg with a certain name to your own config could affect how args for modules imported from another flake are interpreted. Setting _modules.args also affects all modules; an unrelated module could use those deps, which would fail when the imported module providing them is removed. Also the args could conflict between multiple imported modules.

If moduleArgs from the defining flake are needed in a module, it should be a function that takes moduleArgs and returns a module (thus the module does not have them in its args, but rather closes over them.

ratson commented 2 weeks ago

Fair enough, adding global args from an imported module is not a good idea.