Core Concepts
Declarative
A way of specifying what you want (the desired state), rather than how to achieve it (imperative steps). Nix is declarative: you describe your system, and Nix figures out how to build it.
Declarative: "I want Python 3.11"
Imperative: "Run apt-get install python3.11"
Reproducibility
The property that building the same Nix expression in different environments (different machines, times) produces identical results. This is Nix's core promise.
Purity / Pure Function
A function that always produces the same output for the same input, with no side effects. Nix strives for purity to ensure reproducibility—builds shouldn't depend on random system state.
Immutability
Once something is built/stored in Nix, it doesn't change. This prevents accidental modifications and enables safe sharing of built artifacts.
Nix Language & Syntax
Nix Expression
A piece of code in the Nix language that evaluates to a value (often a package, configuration, or derivation). It's the unit of specification in Nix.
{ name = "hello"; version = "1.0"; }
Derivation
A Nix object that describes how to build something (source code → compiled binary). It specifies inputs, build steps, and outputs. Often written as stdenv.mkDerivation { ... }.
Attribute Set
Nix's equivalent of a dictionary or object: a set of key-value pairs. Written with curly braces.
{ name = "alice"; age = 30; email = "alice@example.com"; }
List
An ordered collection of values in Nix, written in square brackets.
[ "hello" "world" 42 ]
String Interpolation
Embedding expressions inside strings using ${...} syntax. The expression is evaluated and its result is inserted into the string.
"Hello, ${name}!"
Function
A reusable block of code that takes inputs and returns an output. In Nix, all functions are pure.
x: x + 1
{ a, b }: a + b
Packages & Environments
nixpkgs
The official Nix package repository; a massive collection of package definitions and tools. Contains tens of thousands of packages ready to use.
nix-shell
A command that drops you into a shell with specific packages available, without permanently installing them. Useful for isolated dev environments.
nix-shell -p nodejs python3 ruby
flake.nix
A modern Nix file format that defines a project's dependencies and outputs. It's reproducible and self-contained—includes a lock file (flake.lock) pinning all dependencies.
flake.lock
An auto-generated lock file that pins exact versions/revisions of all flake inputs. Ensures reproducibility across machines and time.
Overlay
A way to customize or extend nixpkgs without modifying it directly. Overlays let you override packages or add new ones.
System & Configuration
NixOS
A Linux distribution configured entirely by Nix. System configuration (packages, services, settings) is declared in a single configuration file.
configuration.nix
The main NixOS system configuration file. Defines what packages, services, and settings should be on the system.
Home Manager
A tool for managing user-level configuration (shell settings, dotfiles, user packages) declaratively, on any Linux/macOS system (not just NixOS).
Closure
All the dependencies required by a package or system configuration, recursively. Nix tracks closures to ensure everything needed is available.
Store & Build System
Nix Store
The directory (usually /nix/store) where Nix keeps all built packages and dependencies. Everything is stored by content hash.
Garbage Collection
The process of removing unused packages from the Nix store to free disk space. Only removes packages not referenced by any "root".
nix-collect-garbage
Hash / Content Hash
A unique identifier for a package or derivation based on its inputs and build process. Two identical inputs produce the same hash—used for reproducibility.
Build Input
A dependency or tool required to build a derivation. Examples: compiler, library, build tool.