LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix3-flake

manages Nix flakes

TLDR

Show flake outputs
$ nix flake show
copy
Update all inputs in flake.lock
$ nix flake update
copy
Update a single input
$ nix flake update [nixpkgs]
copy
Initialize a flake in the current directory
$ nix flake init
copy
Initialize from a template
$ nix flake init -t [templates#rust]
copy
Check that the flake evaluates and run its checks
$ nix flake check
copy
Show flake metadata and locked inputs
$ nix flake metadata [github:NixOS/nixpkgs]
copy
Create missing lock entries without updating existing ones
$ nix flake lock
copy

SYNOPSIS

nix flake subcommand [options]

DESCRIPTION

nix3-flake is the manual page for nix flake, the command for creating, modifying and querying flakes. A flake is a source tree (usually a Git repository) with a flake.nix at its root declaring its inputs (dependencies) and outputs (packages, dev shells, NixOS configurations and so on). Input versions are pinned in flake.lock.Flakes are referenced with flakerefs such as nixpkgs, github:NixOS/nixpkgs/nixos-unstable, git+https://example.org/repo or a path like .; an output is selected with #, e.g. .#default.

PARAMETERS

show [flake]

Show the outputs provided by a flake. --all-systems includes every system, --json gives machine-readable output.
update [inputs...]
Update the lock file, all inputs by default. --flake url selects another flake than the current directory.
lock
Create missing lock file entries without updating existing ones.
init, new dir
Create a flake in the current (or given) directory from a template (-t).
check
Check whether the flake evaluates and run its tests. --all-systems checks every system.
metadata, info
Show flake metadata such as the locked revision and input tree.
archive
Copy a flake and all its inputs to a store.
clone
Clone a flake's repository.
prefetch, prefetch-inputs
Download a flake source tree, or the inputs of a flake, into the Nix store.
--help
Display help information.

INSTALL

sudo apt install nix-bin
copy
sudo dnf install nix
copy
sudo pacman -S nix
copy
sudo apk add nix
copy
sudo zypper install nix
copy
nix profile install nixpkgs#nix
copy

CAVEATS

There is no nix3 executable: the new-CLI man pages are named nix3-subcommand (man nix3-flake, man nix3-flake-update). Run the commands as nix flake.Requires the nix-command and flakes experimental features. In a Git repository only files tracked by Git are visible to the flake, so git add new files first. nix flake update used to update the flake given as argument; it now takes input names and uses --flake to select the flake.

HISTORY

Flakes and nix flake were introduced as an experimental feature in Nix 2.4 (2021). nix flake info is an older alias of nix flake metadata. Nix 2.19 (2023) changed nix flake update to accept input names, replacing nix flake lock --update-input.

SEE ALSO

RESOURCES

Copied to clipboard
Kai