Skip to content

Commit

Permalink
Merge pull request #10200 from 9999years/fix-nix-eval-for-derivations
Browse files Browse the repository at this point in the history
Fix `nix eval nixpkgs#bash` segfault
  • Loading branch information
tomberek committed Mar 11, 2024
2 parents 72e145e + 7f45b1c commit 25bf671
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 13 additions & 0 deletions doc/manual/rl-next/nix-eval-derivations.md
Original file line number Diff line number Diff line change
@@ -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»
```
13 changes: 11 additions & 2 deletions src/nix/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
);
}
}
};
Expand Down

0 comments on commit 25bf671

Please sign in to comment.