dynamic-derivations¶
Overview¶
The dynamic-derivations experimental feature unlocks a narrow slice of dynamic derivations support in Nix: derivation outputs whose identity is not fully fixed at evaluation time, and dependencies on outputs that are themselves produced as derivation outputs. The manual describes the surface as limited—mainly text-hashing outputs for building .drv files, and dependencies on derivation outputs that are themselves derivation outputs.
Version stamp: As of the Nix 2.34.x stable reference manual (nix.dev/manual/nix/stable/ → 2.34; title 2.34.9), dynamic-derivations remains experimental and must be enabled explicitly (verified on Nix 2.34.8: builtins.outputOf is present only with the flag). This is an advanced, research-oriented area—not a stable packaging API for most workflows. Enable it like other flags (Feature Flags Overview); track stabilisation via Tracking Stabilization and the dynamic-derivations tracking issue.
Details¶
What the flag enables. With dynamic-derivations on, Nix allows:
- Text-hashing derivation outputs — outputs whose store path is computed via text hashing, so a build can produce
.drvfiles as outputs rather than only pre-known fixed paths. Related:outputHashMode = "text"in the floating CA / advanced-attributes model (ca-derivations). - Dependencies on dynamic outputs — a derivation may depend on the output of another derivation when that output is itself a derivation output (not only a statically known store path at eval time).
builtins.outputOf— language access to deriving-path style output references. Given a derivation reference and an output name, it returns a concrete output path when statically known, or an input placeholder when the derivation is content-addressed or itself produced by another derivation. The primop can be nested (output-of-output). It corresponds to the^sigil in deriving-path / installable syntax.
The experimental-features page does not promise a full “derivations created at build time” product behind this single flag; treat the above as the documented scope for Nix 2.34.x. Deeper store-model notes live under Store derivation / deriving path in the 2.34 manual.
Experimental and evolving. Like all experimental features, dynamic-derivations may change or be removed. Behavior, builtins, and CLI affordances can shift between releases—check release notes when upgrading. For a related but distinct capability (builders invoking Nix during a build), see recursive-nix.
Background concepts. Static derivation structure, .drv files, and input addressing are covered in Derivation. How hashes and inputs feed store paths is in Hashing and inputs.
Examples¶
Enable in nix.conf (persistent opt-in; Nix 2.34.x):
Append alongside other flags without replacing an existing list:
One-shot on the command line:
builtins.outputOf availability (verified Nix 2.34.8):
# With the flag: primop is visible
nix-instantiate --extra-experimental-features dynamic-derivations --eval -E 'builtins.outputOf'
# => <PRIMOP>
# Without the flag:
# error: attribute 'outputOf' missing
Chaining shape from the builtins manual (needs real derivation references in a larger expression):
The experimental-features page itself does not ship a minimal end-to-end dynamic-derivation recipe; real use typically pairs this flag with upstream tracking and in-tree experiments rather than copy-paste packaging snippets.
References¶
- Nix manual — Experimental features (
dynamic-derivations, 2.34) — version-stamped flag description - Nix manual — Built-ins (
outputOf) — placeholder / deriving-path behaviour - Nix manual — Store derivation — deriving paths and dynamic-derivation model notes
- Nix manual — nix.conf —
experimental-featuresandextra-experimental-features - dynamic-derivations tracking issue — stabilisation milestone
See also¶
- Feature Flags Overview — how experimental features are enabled and lifecycle
- Tracking Stabilization — which flags have stabilized or remain experimental
- recursive-nix — builders calling Nix during a build (separate flag)
- ca-derivations — floating CA;
outputHashMode = "text"overlap - Derivation — static derivation model and
.drvfiles - Hashing and inputs — how inputs determine store paths