6.5 Exercise: a release.nix for GNU hello
Lesson 44 of 68 · 18:13
Up next in 5s…
About this lesson
Time to do it yourself. You take the GNU hello package from the earlier lessons, normalize its default.nix into a package function, and write a release.nix that exposes three variants: a plain default build, a build with a different compiler, and a patched build. This is the repetition that makes override and overrideAttrs stick.
In this video
- Three package variants from one recipe, each one testing a different skill
- A destructive
overrideAttrsmistake that silently drops a security patch, and the defensive habit that prevents it - Writing overrides that survive attributes which do not exist yet, so a colleague's change next week does not break them
overrideCCas a bonus round: injecting any compiler version you like intostdenv- A first look at
finalAttrsandlib.optionalfor a package that adapts itself to downstream patches
After this lesson
Your fingers know the override workflow, not just your head. This skill is what Nix people use at work all the time, and it is the foundation for overlays later in the course.
Links:
- Exercise source (GNU hello 2.9): https://gnu.mirror.constant.com/hello/hello-2.9.tar.gz
- Solutions: https://nixcademy.com/downloads/hello-release-solution.zip