Nix 101 Course / Section 6: Composing nixpkgs: callPackage, override, project layout
Premium

6.5 Exercise: a release.nix for GNU hello

Lesson 44 of 68 · 18:13

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

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 overrideAttrs mistake 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
  • overrideCC as a bonus round: injecting any compiler version you like into stdenv
  • A first look at finalAttrs and lib.optional for 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: