Skip to content

Commit

Permalink
Print derivation paths in nix eval
Browse files Browse the repository at this point in the history
`nix eval` forces values and prints derivations as attribute sets, so
commands that print derivations (e.g. `nix eval nixpkgs#bash`) will
infinitely loop and segfault.

Printing derivations as `.drv` paths makes `nix eval` complete as
expected. Further work is needed, but this is better than a segfault.
  • Loading branch information
9999years committed Mar 9, 2024
1 parent 3120fef commit 4910d74
Showing 1 changed file with 11 additions and 2 deletions.
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 4910d74

Please sign in to comment.