diff --git a/doc/manual/rl-next/nix-eval-derivations.md b/doc/manual/rl-next/nix-eval-derivations.md new file mode 100644 index 00000000000..ed0a7338464 --- /dev/null +++ b/doc/manual/rl-next/nix-eval-derivations.md @@ -0,0 +1,13 @@ +--- +synopsis: "`nix eval` prints derivations as `.drv` paths" +prs: 10200 +--- + +`nix eval` will now print derivations as their `.drv` paths, rather than as +attribute sets. This makes commands like `nix eval nixpkgs#bash` terminate +instead of infinitely looping into recursive self-referential attributes: + +```ShellSession +$ nix eval nixpkgs#bash +«derivation /nix/store/m32cbgbd598f4w299g0hwyv7gbw6rqcg-bash-5.2p26.drv» +``` diff --git a/src/nix/eval.cc b/src/nix/eval.cc index 2044c8c2b40..088be3b1782 100644 --- a/src/nix/eval.cc +++ b/src/nix/eval.cc @@ -120,8 +120,17 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption } else { - state->forceValueDeep(*v); - logger->cout("%s", ValuePrinter(*state, *v, PrintOptions { .force = true })); + logger->cout( + "%s", + ValuePrinter( + *state, + *v, + PrintOptions { + .force = true, + .derivationPaths = true + } + ) + ); } } };