NixOS Modules

A module is a file containing a Nix expression with a specific structure. It declares options for other modules to define (give a value). It processes them and defines options declared in other modules.

Basics

  • A module is a function that takes an attrset and returns an attrset.
  • It may declare options.
  • It may define option values.
  • When evaluated, it produces a configuration based on the declarations and definitions.
  {lib, ...}: {
    options = {
      name = lib.mkOption {
        type = lib.types.str;
      };
    };
  }

Lib Utilities

mkMerge

mkOverride

mkIf

mkOrder

References:

Backlinks: