nix-packaging

Installation
SKILL.md

Nix Packaging Guide

1. Packaging Mental Model

A Nix package goes through two distinct stages:

  1. Instantiation: The Nix expression evaluates to a .drv file in the store. This is pure evaluation — no I/O, no network, no side effects.
  2. Realisation: The .drv is 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 in nativeBuildInputs or explicitly referenced
  • No /usr/bin, /lib, or other FHS paths exist — hardcoded paths in source must be patched
Installs
2
GitHub Stars
2
First Seen
Jun 28, 2026
nix-packaging — mattstruble/skills