Nix 101 Course / Section 8: Overlays: changes that propagate downstream
Premium

8.7 Exercise: patching across the dependency tree

Lesson 58 of 68 · 28:24

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

The favorite exercise of the whole course, and the one where overlays usually click. You get a miniature repository: a small app that prints ABCD through a multi-level tree of four C++ libraries, and your job is to make it print XYZW. Every trick you would need on a huge real dependency tree appears here in a size you can actually experiment with.

In this video

  • A five package repo (libA through libD plus the app) that mimics a real multi-level dependency tree, no C++ knowledge required
  • Part one: patch all four libraries using only override and overrideAttrs, and feel how the chain grows the deeper the dependency sits
  • Part two: reach the same result with a single overlay, and see what suddenly comes for free, static and cross builds included
  • Why substituteInPlace with a failing replace mode saves you from patches that silently stop applying, including one trap built into the repo on purpose
  • Experiments to run afterwards: reorder the overlays, predict what breaks, and find out why one broken definition never even becomes an error

After this lesson

You have patched a dependency at every depth of a tree, both surgically and globally, and you know the trade-offs of each route. Real life overlays are just this, at larger scale.

Builds on: final vs prev: the two rule flavors (8.5)

Links: