nix-eval
evaluates Nix expressions
TLDR
SYNOPSIS
nix eval [options] [installable]
DESCRIPTION
nix eval evaluates the given Nix expression or installable and prints the result on standard output. Nested attribute values and list items are evaluated too.By default the result is printed as a Nix expression; --json and --raw give output suitable for scripts. It is the new-CLI replacement for nix-instantiate --eval.
PARAMETERS
INSTALLABLE
Flake output attribute, or attribute path when used with --expr or --file.--expr EXPR
Interpret installables as attribute paths relative to this Nix expression.-f, --file FILE
Interpret installables as attribute paths relative to the expression in FILE (- reads stdin). Implies --impure.--json
Output as JSON. Fails if the result contains functions.--raw
Print strings without quotes or escaping. The result must be a string.--apply FUNC
Apply function to result.--write-to PATH
Write a string, or a nested attribute set of strings, as files under PATH.--read-only
Do not instantiate evaluated derivations. Faster, but can fail when store paths of derivations are accessed.--impure
Allow access to mutable paths, environment variables and the current time.--arg NAME EXPR, --argstr NAME STRING
Pass arguments to Nix functions.--debugger
Start an interactive debugger if evaluation fails.--help
Display help information.
INSTALL
CAVEATS
Part of the experimental new Nix CLI: requires the nix-command experimental feature, plus flakes for flake references. Evaluation is pure by default, so builtins.getEnv, builtins.currentTime and paths outside a flake need --impure.
HISTORY
nix eval appeared with the new nix command in Nix 2.0 (2018) and was reworked for flakes and installables in Nix 2.4 (2021).
SEE ALSO
nix(1), nix-repl(1), nix-instantiate(1), nix3-eval(1)
