Nix 101 Course / Section 9: Flakes
Premium

9.2 Anatomy of a flake: inputs, outputs and the lock file

Lesson 60 of 68 · 16:15

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

Every flake.nix file has the same skeleton: a description, flake inputs, and outputs. This lesson takes a minimal flake apart line by line, so flake.lock, legacyPackages and the packages.system.name attribute path stop being mysterious. Along the way you get the full CLI tour: nix build, nix run, nix develop, nix flake show and nix flake check.

In this video

  • Why outputs are a function of inputs, and what the flake.lock file actually pins
  • The odd rule about architectures in packages, and a two-line trick that supports every platform nixpkgs supports
  • Why nixpkgs hides its packages inside legacyPackages, explored live in the REPL with :lf
  • What default means for nix build and nix run, and how a flake references itself through self
  • Catching a broken output structure with nix flake check before anyone else has to tell you

After this lesson

You can read any flake.nix you find on GitHub, add a dev shell to one, and inspect a flake you never checked out using nix flake show.