Skip to content
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

Document NixOS module inputs #132419

Open
domenkozar opened this issue Aug 2, 2021 · 4 comments
Open

Document NixOS module inputs #132419

domenkozar opened this issue Aug 2, 2021 · 4 comments
Labels
6.topic: module system About "NixOS" module system internals 6.topic: nixos

Comments

@domenkozar
Copy link
Member

There's currently no reference documentation (that I could find) listing all module inputs.

For example modulesPath is quite uncommon.

@domenkozar domenkozar added 6.topic: nixos 6.topic: module system About "NixOS" module system internals labels Aug 2, 2021
@infinisil
Copy link
Member

infinisil commented Aug 2, 2021

The NixOS module internally specifies these arguments:

  • lib
  • config
  • options

The module system allows adding arbitrary other arguments however, using either _module.args, args (which is implemented with _module.args) or specialArgs (whose values can be used in imports). NixOS uses these to add some NixOS specific arguments (see https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/eval-config.nix):

  • pkgs via _module.args
  • baseModules via args
  • extraModules via args
  • modules via args
  • modulesPath via specialArgs

Finally, the user can add arbitrary attributes as well using mainly _module.args

@roberth
Copy link
Member

roberth commented Aug 2, 2021

The NixOS module internally specifies these arguments:

The module system internally specifies [...]

It's not NixOS-specific; only pioneered with it. (I know you know; typo?)

pkgs

This one can be set through nixpkgs.pkgs as well, where at can be extended with overlays.

the user can add arbitrary attributes

Should we encourage this though? It's a flat namespace and it's not as powerful as options, iirc. So why not put your stuff in the config namespace?

@infinisil
Copy link
Member

It's not NixOS-specific; only pioneered with it. (I know you know; typo?)

Oh yeah, should be "module system" as you suggest instead :)

Should we encourage this though? It's a flat namespace and it's not as powerful as options, iirc. So why not put your stuff in the config namespace?

I agree that in general it should be discouraged. Though defining options currently has the problem that the type that is being used can influence evaluation of the value. However, it just so happens that I worked on improving this today, see #132448

@infinisil
Copy link
Member

I'm documenting _module.args in #165540

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: module system About "NixOS" module system internals 6.topic: nixos
Projects
None yet
Development

No branches or pull requests

3 participants