LinuxCommandLibrary

nix-instantiate

instantiates Nix expressions, producing store derivations

TLDR

Instantiate expression

$ nix-instantiate [expression.nix]
copy
Evaluate and print
$ nix-instantiate --eval [expression.nix]
copy
Evaluate to JSON
$ nix-instantiate --eval --json [expression.nix]
copy
Parse only (check syntax)
$ nix-instantiate --parse [expression.nix]
copy
Use expression from command line
$ nix-instantiate --eval -E '1 + 2'
copy

SYNOPSIS

nix-instantiate [options] files...

DESCRIPTION

nix-instantiate instantiates Nix expressions, producing store derivations. With --eval, it evaluates expressions and prints results.
This is useful for debugging and testing Nix expressions.

PARAMETERS

--eval

Evaluate and print result.
--json
Output as JSON.
--strict
Evaluate strictly.
--parse
Parse only.
-E expr
Evaluate expression.
--arg name value
Pass argument.
-A attr
Select attribute.

Evaluate expression

nix-instantiate --eval -E 'let x = 1; in x + 1'

Output: 2

Get derivation

nix-instantiate '<nixpkgs>' -A hello

Output: /nix/store/...-hello.drv

$
# CAVEATS

Newer nix commands (nix eval) supersede some uses. Strict evaluation required for full values. Part of legacy Nix CLI.

# HISTORY

nix-instantiate is one of the original Nix commands, part of the core tooling since **Nix** was first released in **2003**.

# SEE ALSO

nix-build(1), nix-store(1), nix-env(1)
copy

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community