8.1 The problem nixpkgs overlays solve
Lesson 52 of 68 · 8:41
Video chapters
-
0:00 Introduction to overlays
-
1:14 Patching package dependencies with overrides
-
3:18 Cascading changes through dependency trees
-
5:43 Why overlays are more powerful than distro patching
-
7:27 What overlays enable in practice
Transcript
Introduction to overlays
0:00 Now about overlays. That's my favorite topic in the whole series and overlays is the single most powerful mechanism inside Nix packages invocations, where you can manipulate everything and anything and that is the thing that most Flakes users have never heard about or never used and many people think that the follows mechanism of Flakes inputs is kind of the substitute of overlays and overlays are old. But that's not true, overlays are much more powerful and you're missing out if you don't know about them. And of course, you can use them with or without Flakes. However, let's have a look at like what it actually is.
0:41 So in general, we have already seen that we can use the override function to manipulate the inputs of one package. So that means that if we have like a package like app one and we want to substitute one input, for example, you have the C library as an example. But it could be anything and you want to substitute that by a different library, then you could basically say app one override and then blah blah blah inject whatever you like. How would that look like?
Patching package dependencies with overrides
1:15 We could say app one equals packages app one. There is no app one in Nix packages, right? But we're just talking examples here. So imagine there would be one. You can say override and then we could say libc equals packages dot libc dot tick or whatever. Let's let's say we have a libc prime that is packages dot libc dot overrideAttrs like this. And then we say patches equals old dot patches or empty list plus plus my patch.
The full transcript comes with the lesson.
About this lesson
You patched one package with override, but now you need that patch in every package that depends on it, directly and indirectly. This video shows why override and overrideAttrs cannot push a change down the dependency tree, and why nixpkgs overlays exist. If you use flakes and think the follows mechanism replaces overlays, this lesson explains what you are missing.
In this video
- Injecting a security patch into
libcfor one app withoverride: easy and clean - The same patch for an app that also pulls
libcin throughboost: watch the code duplication pile up, level by level - The structural limit:
overrideandoverrideAttrsmove up the dependency tree, never down - What happens when only some parts of the tree get the patched library, and why the failure shows up at runtime instead of at build time
- What overlays promise instead: change all packages at once or patch surgically, add new packages, and compose customizations from different teams
After this lesson
You understand exactly which problem overlays solve and why the override chain approach collapses on real dependency trees. The next lessons show the mechanism itself.
Builds on: override vs overrideAttrs (6.4)