:PROPERTIES:
:ID:       01b79396-e6d4-4673-9438-95a120543f05
:END:
#+title: NixOS Modules
#+HUGO_CATEGORIES: "Operating Systems"
#+HUGO_TAGS: "Linux" "Nix" "NixOS"

#+BEGIN_QUOTE
A module is a file containing a [[id:72d705ae-9f5c-402b-88e5-21744277319a][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.
#+END_QUOTE

* 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.

#+BEGIN_SRC nix
  {lib, ...}: {
    options = {
      name = lib.mkOption {
        type = lib.types.str;
      };
    };
  }
#+END_SRC

* Lib Utilities

** mkMerge
** mkOverride
** mkIf
** mkOrder

