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

6.3 How callPackage actually works

Lesson 42 of 68 · 8:17

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

About this lesson

If callPackage felt like magic in the last lesson, this one takes the magic apart. We rebuild the mechanism in the Nix REPL with lib.callPackageWith and tiny toy functions, so you see exactly where the auto-filled arguments come from and where the override attribute on every package is born.

In this video

  • callPackage as a higher-order function, shown with a whiteboard-sized example instead of a real package
  • Preloading callPackageWith with a small attribute set and watching it fill in function parameters
  • What happens with an unknown parameter, and how the error message helps you
  • Where the override function on the result comes from, what it remembers, and how to chain it
  • overrideDerivation: the legacy attribute you will meet in old docs and should ignore

After this lesson

You can explain in one sentence what pkgs.callPackage really is, and you can predict what any override call will do instead of trying things until they work.