Nix — Purely Functional Package Manager
Nix is a purely functional package manager that treats packages as values in a functional programming language — built by pure functions with no side effects, never overwritten after creation. This skill covers the complete Nix manual: language reference, store internals, command-line tools, and protocols.
Key properties:
- •Reproducible: Hermetic builds via pure function semantics — same inputs always produce the same outputs
- •Declarative: Package descriptions are Nix expressions, not imperative scripts
- •Reliable: Atomic upgrades/rollbacks, multiple versions coexist, garbage collection for unused paths
- •Multi-user: Unprivileged users can install packages securely without root
When to use this skill
Invoke when the user asks about:
- •Nix language syntax, builtins, derivations, or evaluation semantics
- •Nix store concepts (store paths, content addressing, file system objects)
- •Nix CLI commands (
nix-build,nix-env,nix-store,nix-shell, etc.) - •Package management (profiles, channels, garbage collection, binary caches)
- •Distributed/remote builds, build reproducibility, caching strategies
- •Nix protocols (NAR format, store path calculation, JSON formats)
- •Nix internals, architecture, or contributing to Nix development
Additional Resources
Overview
- •Introduction — What Nix is and its core features
- •Quick Start — Minimal getting-started guide (install, run, search, GC)
- •Glossary — Definitions of Nix terminology (derivation, store path, closure, etc.)
- •Table of Contents — Master hierarchical index of the entire manual
Installation
- •Installation Overview — Recommended installation methods
- •Installing a Binary Distribution — Install via official script (
curl | sh) - •Using Nix within Docker — Running Nix in Docker containers
- •Supported Platforms — Linux (i686, x86_64, aarch64) and macOS
- •Multi-User Mode — Shared store with build user isolation
- •Single-User Mode — Single-user store ownership
- •Security — Security models and threat prevention
- •Environment Variables — PATH setup and
nix.shsourcing - •Upgrading — Version upgrades via channels
- •Uninstalling — Removal steps for Linux/macOS
- •Building from source: Prerequisites | Obtaining Source | Building | Installing
Nix Language
- •Language Overview — Domain-specific, declarative, pure, lazy, dynamically typed
- •Syntax — Expression syntax and semantics
- •Data Types — Integer, Float, Boolean, String, Path, Null, Attrset, List, Function
- •Variables — Variable binding and usage
- •Identifiers — Naming rules and reserved keywords
- •Scoping Rules —
let,rec,with, and function scopes - •String Literals — Quoted strings, indented strings, URI literals
- •String Interpolation —
${ }syntax in strings, paths, and attribute names - •String Context — Derivation dependency tracking via string contexts
- •Operators — Full operator reference with precedence and associativity
- •Language Constructs — Expression forms and control flow
- •Lookup Path —
<name>resolution viabuiltins.nixPath
- •Lookup Path —
- •Derivations — The
derivationbuiltin and store derivation creation - •Evaluation — How expressions become values (lazy evaluation)
- •Import From Derivation — When expression values depend on build outputs
- •Advanced Attributes — Infrequent derivation attributes (
exportReferencesGraph, etc.) - •Built-in Functions — Reference for all
builtins.*functions
Nix Store
- •Store Overview — Immutable file system abstraction for packages and dependencies
- •Store Object — FSO data + reference set forming a directed graph
- •Store Path — Opaque unique identifiers (e.g.
/nix/store/a040m110...-git-2.38.1) - •File System Object — Simplified FS model (files, directories, symlinks)
- •Building — How derivations are built (input normalization, builder execution)
- •Build Trace — Memoization table for content-addressed derivation outputs
- •Secrets — Why secrets must not be embedded in store objects
- •Derivation Resolution — Replacing inputs with simplest equivalent paths
- •Derivation outputs: Overview | Output Types | Content-Addressed | Input-Addressed
- •Content addressing: FSO | Store Object
- •Math Notation Appendix — Formal notation for store path grammar
Package Management
- •Package Management Overview — Obtaining, installing, upgrading, and erasing packages
- •Profiles — Per-user configurations with atomic upgrades/rollbacks
- •Garbage Collection — Removing unused packages
- •Garbage Collector Roots — Symlinks protecting store paths from GC
- •Binary Cache (HTTP) — Serving a Nix store as a binary cache
- •SSH Substituter — Fetching binaries from remote stores via SSH
- •Sharing Packages — Copying packages between machines
Command Reference
- •Command Reference Overview — Index of all Nix commands
- •Common Options — Universal CLI options (
--help, etc.) - •Common Environment Variables —
NIX_PATH,IN_NIX_SHELL, etc. - •Configuration File (
nix.conf) — Settings and format - •Build Failure Exit Codes — Exit codes 100 (generic), 101 (timeout), etc.
Main Commands
- •
nix-build— Build a Nix expression - •
nix-shell— Interactive shell from Nix expression - •
nix-store— Manipulate/query the store - •
nix-env— Manage user environments - •
nix-channel— Manage Nix channels - •
nix-collect-garbage— Delete unreachable store objects - •
nix-instantiate— Instantiate store derivations from expressions - •
nix-hash— Compute cryptographic hashes - •
nix-prefetch-url— Download URL to store and print hash - •
nix-copy-closure— Copy closures to/from remote machines - •
nix-daemon— Multi-user support daemon
nix-env Subcommands
- •install | uninstall | upgrade | query | set | set-flag | rollback | switch-generation | switch-profile | list-generations | delete-generations
nix-store Subcommands
- •realise | gc | delete | query | add | add-fixed | verify | verify-path | repair-path | dump | dump-db | restore | export | import | optimise | read-log | print-env | generate-binary-cache-key | serve | load-db
Files
- •
Profiles | Channels | Default Nix Expression | manifest.json | manifest.nix
- •
Experimental Commands — Unstable commands subject to change
- •
Utilities — Additional utility tools
Advanced Topics
- •Advanced Topics Overview — Build performance and advanced build features
- •Tuning Cores and Jobs — Configuring
coresandmax-jobsfor CPU utilization - •Verifying Build Reproducibility — Using
diff-hookto compare builds - •Remote/Distributed Builds — Forwarding builds to other machines
- •Evaluation Profiler — Flamegraph-compatible profiling of Nix evaluation
- •Post-Build Hook — Auto-running scripts after builds (e.g. upload to cache)
Protocols
- •Protocols Overview — Developer-facing interfaces provided by Nix
- •Store Path Calculation — Full EBNF spec for computing store paths
- •Derivation ATerm Format — On-disk serialization (
Derive(...)) - •Tarball Fetcher Protocol — Lockable HTTP tarball serving via
Linkheader - •Nix Archive (NAR) Format — EBNF spec for FSO tree serialization
- •JSON formats: Index | Build Result | Store Path | Store | Store Object Info | Content Address | Hash | Deriving Path | FSO | Build Trace Entry | Derivation | Derivation Options
Architecture
- •Architecture — Internal component hierarchy and concept map
Development (Contributing to Nix)
- •Development Overview — Entry points for contributing
- •Building Nix — Cloning and building from source
- •Testing — Coverage analysis and test execution
- •Debugging — Debug symbols and debugging in tests
- •Contributing — Release note format and PR conventions
- •CLI Guideline — UX design guidelines for
nixcommands - •JSON Guideline — Consistent JSON interface practices
- •C++ Style Guide — C++ conventions and
*-impl.hhpattern - •Documentation — Contributing docs, building the manual
- •Experimental Features — Feature flag system for unstable functionality
- •Benchmarking — Google Benchmark framework usage
C API
- •C API — In-development stable C API with auto-generated documentation
Release Notes
- •Release Notes Index — All release notes from Nix 0.5 through 2.33
Assets
- •
figures/user-environments.png— User environments diagram - •
figures/user-environments.sxd— Source for user environments diagram