8.7 Exercise: patching across the dependency tree
Lesson 58 of 68 · 28:24
Up next in 5s…
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 (
libAthroughlibDplus the app) that mimics a real multi-level dependency tree, no C++ knowledge required - Part one: patch all four libraries using only
overrideandoverrideAttrs, 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
substituteInPlacewith 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:
- Exercise repository: https://github.com/nixcademy/multi-project-repo
- Solution branch for part 1 (overrides): https://github.com/nixcademy/multi-project-repo/tree/solution-1
- Solution branch for part 2 (overlay): https://github.com/nixcademy/multi-project-repo/tree/solution-2