nix-packaging
Installation
SKILL.md
Nix Packaging Guide
1. Packaging Mental Model
A Nix package goes through two distinct stages:
- Instantiation: The Nix expression evaluates to a
.drvfile in the store. This is pure evaluation — no I/O, no network, no side effects. - Realisation: The
.drvis built, producing a store path like/nix/store/abc123-mypkg-1.0/. This is where compilation happens.
Every package installs to its own unique store path ($out). Nothing is shared via FHS paths like /usr/lib — every dependency is referenced by its full store path.
Why everything must be explicit:
- The sandbox blocks all network access during realisation (except for Fixed-Output Derivations)
- There is no implicit
PATH— tools must be innativeBuildInputsor explicitly referenced - No
/usr/bin,/lib, or other FHS paths exist — hardcoded paths in source must be patched