Nix flakes
| created | 2026-02-19 19:38 |
| modified | 2026-05-27 07:50 |
| tags | nix |
| status | stub |
What they do
They extra-ensure reproducible builds through the use of a flake.lock file, which includes revisions and hashes for each dependency. Without flakes, you can’t pin dependency versions.
How they’re written
A Nix flake is just an attribute set consisting of two attributes: inputs and outputs.
The inputs attribute is a list of flakes to be used as dependencies for your own flake. You define them with a URL, and you can optionally include a revision (commit hash, tag, etc.) to pin to a specific version.
The outputs attribute is actually a FUNCTION. It accepts all the input flakes you defined, evaluates those flakes, and uses them like function parameters to evaluate the function body.
How they’re used
The result of the output function can be anything, but there are a few main use cases for flakes which all have a standardized convention.
Sample flake.nix
{
description = "An example Nix flake definition";
inputs = {
};
outputs = {
} @ inputs: {
};
}