docs: properly explain conversions in nix eval --json/--raw options.
jade: I rewrote this PR to be consistent between nix-instantiate and nix eval. It turns out that nix eval *doesn't* copy to store with `--json`, whereas nix-instantiate does. Wat. Closes: https://github.com/lix-project/lix/pull/17 Co-authored-by: tyberiusprime <tyberiusprime@noreply.git.lix.systems> Change-Id: Id22deec1cee0fed3bd5689567869b70bab26bae5
This commit is contained in:
@@ -107,20 +107,27 @@ See that section for complete details (`nix-build --help`), but in summary, a pa
|
||||
> This option can cause non-termination, because lazy data
|
||||
> structures can be infinitely large.
|
||||
|
||||
- `--raw`
|
||||
- `--raw`\
|
||||
When used with `--eval`, the result must be coercible to a string, i.e.,
|
||||
something that can be converted using `${...}`. The output is
|
||||
printed exactly as-is, with no quotes, escaping, or trailing newline.
|
||||
something that can be converted using `${...}`.
|
||||
|
||||
Integers will always generate an error when output via `--raw`, regardless of
|
||||
[`coerce-integers`](../contributing/experimental-features.md#xp-feature-coerce-integers) being enabled, to avoid ambiguity.
|
||||
|
||||
The output is printed exactly as-is, with no quotes, escaping, or trailing
|
||||
newline.
|
||||
|
||||
- `--json`\
|
||||
When used with `--eval`, print the resulting value as an JSON
|
||||
representation of the abstract syntax tree rather than as a Nix expression.
|
||||
representation of the resulting value rather than as a Nix expression.
|
||||
|
||||
The conversion behaviour, if `--strict` is passed, is the same as
|
||||
[`builtins.toJSON`](../language/builtins.md#builtins-toJSON).
|
||||
|
||||
- `--xml`\
|
||||
When used with `--eval`, print the resulting value as an XML
|
||||
representation of the abstract syntax tree rather than as a Nix expression.
|
||||
The schema is the same as that used by the [`toXML`
|
||||
built-in](../language/builtins.md).
|
||||
representation of the resulting value rather than as a Nix expression.
|
||||
The schema is the same as that used by [`builtins.toXML`](../language/builtins.md#builtins-toXML).
|
||||
|
||||
- `--read-write-mode`\
|
||||
When used with `--eval`, perform evaluation in read/write mode so
|
||||
|
||||
+13
-5
@@ -61,12 +61,20 @@ result on standard output.
|
||||
|
||||
* 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 `--json`, the evaluation result is printed in JSON format.
|
||||
|
||||
* With `--raw`, the evaluation result must be a string, which is
|
||||
printed verbatim, without any quoting.
|
||||
The conversion behaviour is the same as
|
||||
[`builtins.toJSON`](../../language/builtins.md#builtins-toJSON) except that
|
||||
paths are printed as-is without being copied to the Nix store.
|
||||
|
||||
* With `--raw`, the result must be coercible to a string, i.e.,
|
||||
something that can be converted using `${...}`.
|
||||
|
||||
Integers will always generate an error when output via `--raw`, regardless of
|
||||
[`coerce-integers`](../../contributing/experimental-features.md#xp-feature-coerce-integers) being enabled, to avoid ambiguity.
|
||||
|
||||
The output is printed exactly as-is, with no quotes, escaping, or trailing
|
||||
newline.
|
||||
|
||||
* With `--write-to` *path*, the evaluation result must be a string or
|
||||
a nested attribute set whose leaf values are strings. These strings
|
||||
|
||||
Reference in New Issue
Block a user