The Brewhouse · Step 2 of 5 · Bottle-conditioned

Flakes

Flakes bottle your config: a flake.nix says which ingredients you use, and a flake.lock records the exact version of each one. Rebuild next month, or on another PC, and you get the same system.

Who it's for

Anyone keeping their config in git, and anyone reading other people’s configs, since most of them use flakes.

Move up when

Your flake.nix is crowded with several machines and shared modules, and you want some structure.

The pour

Your configuration.nix doesn’t change at all. A flake.nix sits next to it and says where everything comes from:

# flake.nix
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";

  outputs = { nixpkgs, ... }: {
    nixosConfigurations.endgame = nixpkgs.lib.nixosSystem {
      modules = [ ./configuration.nix ];   # programs.steam.enable = true; lives in here
    };
  };
}

Build the machine called endgame:

sudo nixos-rebuild switch --flake .#endgame

How it works

The first build writes flake.lock, pinning the exact nixpkgs commit. Commit both files. To update, run nix flake update and rebuild. If the new versions misbehave, roll back as usual or revert the lock file in git.

To switch flakes on, add this to your config and rebuild once:

nix.settings.experimental-features = [ "nix-command" "flakes" ];

A second machine is just another entry under nixosConfigurations, pointing at its own files.

Why people like it

  • Reproducible: flake.lock pins every input, so nothing changes until you run nix flake update.
  • Lives anywhere (usually a git repo in your home folder) and builds any machine by name.
  • Pull in extra sources, like Home Manager or a hardware repo, as inputs.

What it costs you

  • Still labelled experimental in Nix, so you switch it on with one setting. In practice most of the community uses it.
  • Flakes only see files tracked by git. Forget to git add a new file and the build won’t find it.
  • One more file and one more concept to learn up front.

Regulars brewed this way

Misterio77/nix-starter-configs
Gabriel Fontes
First pint

Minimal and standard flake templates with heavy comments, designed to be the thing you copy on day one.

Worth borrowing: The whole thing. Start your own config from the minimal template.
mitchellh/nixos-config
Mitchell Hashimoto
Second round

Runs NixOS in a VM on a Mac as a daily development machine. A neat look at Nix outside a normal PC.

Worth borrowing: The idea that your dev environment can live in a VM you rebuild at will.

Further reading

Last checked against the projects' own docs: 11 November 2026. These tools move quickly; spotted something out of date? Open a pull request.