Nix 101 Course / Section 4: How Nix actually builds: sandbox → derivation → hash → store
Premium

4.1 What actually happens when you run nix build

Lesson 24 of 68 · 11:54

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

You type nix build and a store path falls out. This lesson opens up what happens in between: how a Nix expression turns into a derivation, and how a derivation turns into a path in the Nix store. That pipeline is the foundation of reproducible builds, and knowing it is what lets you debug packaging problems instead of guessing.

In this video

  • The three stage pipeline behind every build: Nix expression, derivation file, Nix store path, and the commands (nix-instantiate, nix-store --realise) that run each stage on its own
  • Why the Nix daemon never sees a single line of Nix code, and what it receives instead
  • Derivations compared to Dockerfiles, and the one design choice Nix makes the other way around: which end of the build gets hashed
  • What counts as an input: source code, compiler, build system, and every environment variable that could change the result
  • Why this course waits with flakes, shown with the same example written both ways

After this lesson

You can name every intermediate artifact between pressing enter and getting a store path, and you know which stage the words evaluate, instantiate, and realize belong to. The whole packaging section builds on this map.