A file with inputs and outputs.
A flake is a source tree with a flake.nix entry point. Its outputs function receives resolved inputs and returns an attribute set. Common output names let commands discover packages and development shells.
The upstream Nix manual still marks flakes and the new command interface experimental. This course uses that interface explicitly. Enable nix-command and flakes for these lessons, or supply the flags per command.
# One-command enablement, without editing settings:
nix --extra-experimental-features "nix-command flakes" flake --help
# For a persistent user setting, add to:
# ~/.config/nix/nix.conf
# extra-experimental-features = nix-command flakes
A small, recognizable interface.
The following shows the basic shape, not a package you can build yet. nixpkgs is an input; outputs is a function. The ellipsis accepts additional arguments such as self.
On NixOS, configure the feature through nix.settings.experimental-features = [ "nix-command" "flakes" ]; in your system configuration, then rebuild.
{
description = "My first Nix project";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { nixpkgs, ... }: {
# Packages and shells go here.
};
}
flake.nix defines the interface; flake.lock records resolved external inputs.