This is the first in a series of blog posts intended to provide a gentle introduction to flakes , a new Nix feature that improves reproducibility, composability and usability in the Nix ecosystem. This blog post describes why flakes were introduced, and give a short tutorial on how to use them.
Flakes were developed at Tweag and funded by Target Corporation and Tweag.
Flakes solve a couple of problems:
- ensuring reproducible evaluation of things like NixOS system configurations requires special care
- no standard way to compose Nix-based projects
- no easy way to deliver Nix-based projects to users
A flake is simply a source tree (such as a Git repository) containing a file named
flake.nix
that provides a standardized interface to Nix artifacts such as packages or NixOS modules. Flakes can have dependencies on other flakes, with a “lock file” pinning those dependencies to exact revisions to ensure reproducible evaluation.