modules

The list of arguments to a module are

  • config: option definitions (setting options)
  • lib: Nixpkg's library functions
  • pkgs: reference to Nixpkgs
  • options: option declarations (defining options)
  • modulesPath: path to Nixpkg's NixOS modules

These are documented in NixOS Manual - Writing NixOS Modules.

Using lib instead of pkgs.lib can sometime prevent infinite recursion errors.