nix3-eval(1)
π nix3-eval β like, the manual page bestie
okay so grab a snack and sit down, because we're doing nix3-eval(1) from the General Commands Manual and honestly? she's iconic. πΈ
β οΈ Warning β οΈ This program is experimental and its interface is subject to change. Like, it WILL ghost you and change its whole personality. no cap.
β¨ Name β¨
nix eval β evaluate a Nix expression π§
π Synopsis π
nix eval [optionβ¦] installable
π Examples π
okay these are the vibes, bestie, eat them up:
- Evaluate a Nix expression given on the command line:
# nix eval --expr '1 + 2'
- Evaluate a Nix expression to JSON:
# nix eval --json --expr '{ x = 1; }'
{"x":1}
- Evaluate a Nix expression from a file:
# nix eval --file ./my-nixpkgs hello.name
- Get the current version of the nixpkgs flake:
# nix eval --raw nixpkgs#lib.version
- Print the store path of the Hello package:
# nix eval --raw nixpkgs#hello
- Get a list of checks in the nix flake:
# nix eval nix#checks.x86_64-linux --apply builtins.attrNames
- Generate a directory with the specified contents:
# nix eval --write-to ./out --expr '{ foo = "bar"; subdir.bla = "123"; }'
# cat ./out/foo
bar
# cat ./out/subdir/bla
123
π Description π
This command evaluates the Nix expression you hand it, and prints the result on standard output. that's the whole job. that's the assignment. π
It also evaluates any nested attribute values and list items. like, it goes deep. main character energy.
π¦ Output format π¦
nix eval can produce output in several formats:
- By default, the evaluation result is printed as a Nix expression.
- With
--json, the evaluation result is printed in JSON format. Note that this fails if the result contains values that are not representable as JSON, such as functions. π - With
--raw, the evaluation result must be a string, which is printed verbatim, without any quoting. - With
--write-topath, the evaluation result must be a string or a nested attribute set whose leaf values are strings. These strings are written to files named path/attrpath. path must not already exist. π
β¨ OPTIONS β¨
--applyexpr β Apply the function expr to each argument.--jsonβ Produce output in JSON format, suitable for consumption by another program.--no-prettyβ Print compact JSON output on a single line, even when the output is a terminal. Some commands may print multiple JSON objects on separate lines. See--pretty.--prettyβ Print multi-line, indented JSON output for readability. Default: indent if output is to a terminal. This option is only effective when--jsonis also specified.--rawβ Print strings without quotes or escaping.--read-onlyβ Do not instantiate each evaluated derivation. This improves performance, but can cause errors when accessing store paths of derivations during evaluation.--write-topath β Write a string or attrset of strings to path.
π Common evaluation options π
--argname expr β Pass the value expr as the argument name to Nix functions.--arg-from-filename path β Pass the contents of file path as the argument name to Nix functions.--arg-from-stdinname β Pass the contents of stdin as the argument name to Nix functions.--argstrname string β Pass the string string as the argument name to Nix functions.--debuggerβ Start an interactive environment if evaluation fails.--eval-storestore-url β The URL of the Nix store to use for evaluation, i.e. to store derivations (.drvfiles) and inputs referenced by them.--impureβ Allow access to mutable paths and repositories.--include/-Ipath β Add path to search path entries used to resolve lookup paths. This option may be given multiple times. Paths added through-Itake precedence over thenix-pathconfiguration setting and theNIX_PATHenvironment variable.--override-flakeoriginal-ref resolved-ref β Override the flake registries, redirecting original-ref to resolved-ref.
π§ Common flake-related options π§
--commit-lock-fileβ Commit changes to the flake's lock file.--inputs-fromflake-url β Use the inputs of the specified flake as registry entries.--no-registriesβ Don't allow lookups in the flake registries.
DEPRECATED π Use --no-use-registries instead.
--no-update-lock-fileβ Do not allow any updates to the flake's lock file.--no-write-lock-fileβ Do not write the flake's newly generated lock file.--output-lock-fileflake-lock-path β Write the given lock file instead offlake.lockwithin the top-level flake.--override-inputinput-path flake-url β Override a specific flake input (e.g.dwarffs/nixpkgs). The input path must not be empty. This implies--no-write-lock-file.--recreate-lock-fileβ Recreate the flake's lock file from scratch.
DEPRECATED π Use nix flake update instead.
--reference-lock-fileflake-lock-path β Read the given lock file instead offlake.lockwithin the top-level flake.--update-inputinput-path β Update a specific flake input (ignoring its previous entry in the lock file).
DEPRECATED π Use nix flake update instead.
π Logging-related options π
--debugβ Set the logging verbosity level to 'debug'.--log-formatformat β Set the format of log output; one ofraw,internal-json,barorbar-with-logs.--print-build-logs/-Lβ Print full build logs on standard error.--quietβ Decrease the logging verbosity level.--verbose/-vβ Increase the logging verbosity level.
π Miscellaneous global options π
--helpβ Show usage information.--offlineβ Disable substituters and consider all previously downloaded files up-to-date.--optionname value β Set the Nix configuration setting name to value (overridingnix.conf).--refreshβ Consider all previously downloaded files out-of-date.--repairβ During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.--versionβ Show version information.
π Options that change the interpretation of installables π
--exprexpr β Interpret installables as attribute paths relative to the Nix expression expr.--file/-ffile β Interpret installables as attribute paths relative to the Nix expression stored in file. If file is the character-, then a Nix expression is read from standard input. Implies--impure.
Note π See man nix.conf for overriding configuration settings with command line flags.
and that's the whole thing, bestie, you ate. π«Ά this page came from nix3-eval(1) β General Commands Manual, dated (you know the date, it's literally in the footer of the original) β so yeah, go forth and eval responsibly. periodt. π
π¦ where this page comes from
- fedora 44: nix-core 2.35.3-2.fc44 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms