5.5 Exercise: extend GNU hello
Lesson 34 of 68 · 28:25
Up next in 5s…
About this lesson
Time to get your hands dirty. In this exercise you rebuild GNU hello, but now you write the configure, build, check, and install phases yourself, then change the program's greeting with your own patch file. Things break in exactly the ways real packages break, and by the end you have followed the trail all the way into the shell script where every stdenv default is defined.
In this video
- Writing all four core phases by hand, and discovering why the install step suddenly fails once you do
- Creating a patch with
diff, handing it to thepatchesparameter, and watching it apply before configure runs - A tool that goes missing mid-build, and deciding whether it belongs in
buildInputsornativeBuildInputs - Tests that start failing for a reason you caused yourself, and the two ways out
- Following
nix derivation showto the roughly 2000 linesetup.shwhere the unpack, patch, configure, and build logic actually lives
After this lesson
You can take over any phase of a build and patch upstream source code without forking it, and when a default phase behaves strangely you know exactly which file to open to see why.
Links:
- Exercise source (GNU hello 2.9): https://gnu.mirror.constant.com/hello/hello-2.9.tar.gz
- Solutions: https://nixcademy.com/downloads/hello-solution.zip