Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Flakes

A flake is a pinned project interface. It declares inputs, records exact input revisions in flake.lock, and exposes outputs that commands can build or inspect.

PartRole
inputs.nixpkgsMain Nixpkgs channel for systems and packages.
inputs.nixpkgs-unstableFast-moving packages, including Zed and AI agent CLIs.
inputs.home-managerUser environment as part of each NixOS system.
inputs.sops-nixSecret material decrypted onto NixOS hosts.
outputs.nixosConfigurationsBuildable NixOS hosts.

The important command target is:

.#nixosConfigurations.<hostname>

nixos-rebuild --flake .#<hostname> is shorthand for selecting one of those host outputs.

Lock file

flake.lock is part of the system definition. Rebuilding without changing it uses the same upstream source graph. Updating it changes package and module inputs, so treat lock updates as intentional system changes.

Use targeted updates when possible:

nix flake lock --update-input nixpkgs-unstable

Use broad updates when the task is a full system refresh:

nix flake update

After changing inputs, evaluate or test one host before switching every host.