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

6.4 override vs overrideAttrs

Lesson 43 of 68 · 13:00

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

Both override and overrideAttrs change a package, so which one do you use when? This lesson draws the line precisely: one re-calls your package function with different arguments, the other changes what goes into mkDerivation itself. We prove the difference on GNU hello with a compiler swap and a patch list.

In this video

  • The one picture that shows what override can touch and what only overrideAttrs can reach
  • Building single attributes from a release.nix with nix build -A, and what your CI should build
  • Swapping stdenv for clangStdenv with override and confirming it in the configure output
  • Changing the patches list with overrideAttrs, and why override cannot do that here
  • Reading the old attributes before you change them, the part that confuses everyone at first

After this lesson

For any change you want to make to a package, you can name the right function in seconds and write the override without guessing. This is the exact question we get in every training, answered for good.