# Import list in \`configuration.nix\` vs \`import\` function

**URL:** https://discourse.nixos.org/t/import-list-in-configuration-nix-vs-import-function/11372
**Category:** Uncategorized
**Created:** [February 3, 2021, 1:56pm UTC](https://discourse.nixos.org/t/import-list-in-configuration-nix-vs-import-function/11372 "2021-02-03T13:56:24Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![jtojnar](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jtojnar/32/70_2.png) [@jtojnar](https://discourse.nixos.org/u/jtojnar)
#### Post date: [February 3, 2021, 5:45pm UTC](https://discourse.nixos.org/t/import-list-in-configuration-nix-vs-import-function/11372/5 "2021-02-03T17:45:16Z")

</div>

Yeah, that is mostly an implementation detail and I will send you to the [module system source code](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/lib/modules.nix) if you want to learn more. I can only describe what it seems to do on the outside as I have not actually needed to dig any deeper than the stuff I linked.

The module system, roughly, collects all modules, starting with the module inside the `<nixos-config>` file (usually `configuration.nix`) and the default modules from [`module-list.nix`](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/nixos/modules/module-list.nix), and then adding stuff listed in their `imports`, recursively. [Then](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/lib/modules.nix#L187-L191) paths in `imports` are `import`ed. [Next](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/lib/modules.nix#L284-L312), if a collected module is a function expression, it gets passed [`lib`, `config`, `options`](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/lib/modules.nix#L130) and [`pkgs`](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/nixos/lib/eval-config.nix#L50) as arguments (the latter through internal `_module.args.pkgs` option), plus whatever is passed to [`specialArgs` or `extraArgs`](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/nixos/lib/eval-config.nix#L18-L21) (when calling `eval-config` manually, e.g. using [`lib.nixosSystem`](https://github.com/NixOS/nixpkgs/blob/dfab15bd086ed794229200fe256b836b466b4017/flake.nix#L28-L48) in a flake, but that is [discouraged](https://github.com/NixOS/nixpkgs/blob/5c7a370a208d93d458193fc05ed84ced0ba7f387/lib/modules.nix#L64-L70)). Then all the resulting attribute sets (mainly containing `options`, `config` attributes) are merged resulting in a single big attribute set.

(By the steps described, I do not mean neatly delineated phases but rather climbing up the function call stack.)

---

_[View the full topic](https://discourse.nixos.org/t/import-list-in-configuration-nix-vs-import-function/11372)._
