Nix 101 Course / Section 5: Packaging real software with stdenv.mkDerivation
Premium

5.5 Exercise: extend GNU hello

Lesson 34 of 68 · 28:25

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

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 the patches parameter, and watching it apply before configure runs
  • A tool that goes missing mid-build, and deciding whether it belongs in buildInputs or nativeBuildInputs
  • Tests that start failing for a reason you caused yourself, and the two ways out
  • Following nix derivation show to the roughly 2000 line setup.sh where 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: