Nix 101 Course / Section 6: Composing nixpkgs: callPackage, override, project layout
Premium

6.7 Import from derivation (IFD) and why teams ban it

Lesson 46 of 68 · 13:45

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

Import from derivation (IFD) is the anti-pattern people keep hearing about without knowing what it means. In this lesson we build the smallest possible IFD example: a Nix expression that generates another Nix expression, imports it, and builds it. Then you watch exactly how it stalls evaluation, and why many organizations forbid it outright.

In this video

  • A minimal IFD demo you can reproduce: runCommand writing a hello.nix, then callPackage on its output
  • The caching behavior: which edit forces the slow wait again and which one comes straight from the cache
  • Why IFD does not parallelize: the evaluator blocks on every generated expression, one after another
  • How one second per project turns into a silent terminal for 10 or 40 minutes on the system image team's machine
  • Crane vs naersk for Rust: two answers to the same problem, only one of them uses IFD, plus the cross-compilation trap

After this lesson

You can recognize IFD in your own code, predict what it costs downstream, and demonstrate the problem to a colleague who does not believe it yet.

Links: