6.6 Nix anti-patterns that bite you later
Lesson 45 of 68 · 15:43
Up next in 5s…
About this lesson
None of these Nix anti-patterns look wrong when you write them. They bite months later, in 500 line files, when nobody can tell where a variable comes from or why an overlay is silently ignored. This lesson collects the patterns we have seen cause pain in many organizations: overused with, rec, accidental nixpkgs re-imports, wiped build phases, and misused callPackage.
In this video
- Why
with pkgs;at the top of a file hurts every future reader, and theinheritstyle that replaces it - The
reckeyword: easy to write, expensive to read, and what to do instead - Reusing
versioninside a derivation, and the subtle way overrides then stop working as expected - nixpkgs amnesia: the forgotten function parameter that quietly throws away your overlays, config and pin
- Overriding a whole build phase and deleting hooks other people rely on, plus the
callPackagemisuse that stacks overrides on overrides (and the function that exists for exactly that case)
After this lesson
You can spot these patterns in code review before they land, and explain to a colleague why the fix matters, not just that it does.
Builds on: override vs overrideAttrs (6.4)