Flakes (Nix)
In spirits it’s very similar to tool like bundler, maven, meson or uv in that it ensure a reproducible set of dependancies and their version, but on a more general scope including the tools ecosystem itself.
Flakes are now the standard way to use Nix.
| Aspect | Nix flakes | uv (as example) |
|---|---|---|
| Locking | flake.lock (pins all inputs) |
uv.lock (pins Python deps) |
| Determinism | Full system-level determinism | Python dependency determinism |
| Solver | Nix evaluator + fetchers | Custom Rust resolver (pip-compatible) |
Using Flakes (Recommended)
Flakes need to be enabled
$ mkdir -p ~/.config/nix
$ echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
# Restart your shell againIt provide a more advanced Workflow for Using Flakes, targeting more specifically developer and project build repetability. see below
Create a new project directory
This directory will contain:
- your Zig code
- your
flake.nix
$ mkdir zig-dev
$ cd zig-devCreate the flake.nix file
A flake is defined entirely by this file.
$ touch flake.nixDefine the flake skeleton
{
description = "Zig development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = { self, nixpkgs }:
{
};
}Enter the Zig development environment
This create an isolated shell, taking into account the flake definition.
$ nix develop
Written on February 5, 2021, Last update on January 24, 2025
nix
package
build-system