The installables syntax is not documented in any of the man pages or
docbook pages for any of those individual commands. And while these
commands really should at least peripherally individually document how
installables work, in the meantime we can at least direct people to the
right place.
This commit also clarifies the unexpected fact that `nix profile remove`
and `nix profile upgrade` do *not* take installables.
Change-Id: I3b1453cb197a613bbab639c66a466365c3592c6d
1.8 KiB
R""(
Note: this command's interface is based heavily around installables, which you may want to read about first (nix --help
).
Examples
-
Evaluate a Nix expression given on the command line:
# nix eval --expr '1 + 2'
-
Evaluate a Nix expression to JSON using the short-form expression flag:
# nix eval --json -E '{ 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 given Nix expression and prints the result on standard output.
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-to
path, 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.
)""