Home Explore Blog Models CI



nixpkgs

nixos/doc/manual/administration/nixos-state.section.md
c2505964bf6c793574c6150b8b404246a6d6fad746d0c84f0000000300000459
# NixOS {#sec-nixos-state}

## `/nix` {#sec-state-nix}

NixOS needs the entirety of `/nix` to be persistent, as it includes:
- `/nix/store`, which contains all the system's executables, libraries, and supporting data;
- `/nix/var/nix`, which contains:
  - the Nix daemon's database;
  - roots whose transitive closure is preserved when garbage-collecting the Nix store;
  - system-wide and per-user profiles.

## `/boot` {#sec-state-boot}

`/boot` should also be persistent, as it contains:
- the kernel and initrd which the bootloader loads,
- the bootloader's configuration, including the kernel's command-line which
  determines the store path to use as system environment.


## Users and groups {#sec-state-users}

- `/var/lib/nixos` should persist: it holds state needed to generate stable
  uids and gids for declaratively-managed users and groups, etc.
- `users.mutableUsers` should be false, *or* the following files under `/etc`
  should all persist:
  - {manpage}`passwd(5)` and {manpage}`group(5)`,
  - {manpage}`shadow(5)` and {manpage}`gshadow(5)`,
  - {manpage}`subuid(5)` and {manpage}`subgid(5)`.

Chunks
d5c7683a (1st chunk of `nixos/doc/manual/administration/nixos-state.section.md`)
Title: NixOS Persistence Requirements for Key Directories and User Data
Summary
This section outlines the essential persistence requirements for a NixOS system. It specifies that the entire `/nix` directory must be persistent, as it houses the `/nix/store` (executables, libraries, data) and `/nix/var/nix` (Nix daemon database, garbage collection roots, user profiles). Additionally, `/boot` needs to be persistent for the kernel, initrd, and bootloader configuration. Finally, `/var/lib/nixos` should persist for stable user and group IDs, and if `users.mutableUsers` is enabled, several `/etc` files like `passwd`, `group`, `shadow`, `gshadow`, `subuid`, and `subgid` must also be persistent.