mirror of
https://github.com/NixOS/nix
synced 2025-07-10 17:13:53 +02:00
printValueAsJSON(): Don't devirtualize
This is already done by consumers of builtins.toJSON (like builtins.toFile or builtins.derivation), so we can delay this until it's actually needed.
This commit is contained in:
parent
2bbf755bee
commit
6023688c6c
3 changed files with 10 additions and 7 deletions
|
@ -249,7 +249,11 @@ private:
|
||||||
|
|
||||||
void printString(Value & v)
|
void printString(Value & v)
|
||||||
{
|
{
|
||||||
printLiteralString(output, v.string_view(), options.maxStringLength, options.ansiColors);
|
NixStringContext context;
|
||||||
|
copyContext(v, context);
|
||||||
|
std::ostringstream s;
|
||||||
|
printLiteralString(s, v.string_view(), options.maxStringLength, options.ansiColors);
|
||||||
|
output << state.devirtualize(s.str(), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPath(Value & v)
|
void printPath(Value & v)
|
||||||
|
|
|
@ -32,11 +32,7 @@ json printValueAsJSON(EvalState & state, bool strict,
|
||||||
|
|
||||||
case nString:
|
case nString:
|
||||||
copyContext(v, context);
|
copyContext(v, context);
|
||||||
// FIXME: only use the context from `v`.
|
out = v.c_str();
|
||||||
// FIXME: make devirtualization configurable?
|
|
||||||
// FIXME: don't devirtualize here? It's redundant if
|
|
||||||
// 'toFile' or 'derivation' also do it.
|
|
||||||
out = state.devirtualize(v.c_str(), context);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nPath:
|
case nPath:
|
||||||
|
|
|
@ -122,7 +122,10 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (json) {
|
else if (json) {
|
||||||
logger->cout("%s", printValueAsJSON(*state, true, *v, pos, context, false));
|
logger->cout("%s",
|
||||||
|
state->devirtualize(
|
||||||
|
printValueAsJSON(*state, true, *v, pos, context, false).dump(),
|
||||||
|
context));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue