Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/nix-instantiate/nix-instantiate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static Path gcRoot;
static int rootNr = 0;


enum OutputKind { okPlain, okXML, okJSON };
enum OutputKind { okPlain, okXML, okJSON, okRaw };


void processExpr(EvalState & state, const Strings & attrPaths,
Expand Down Expand Up @@ -54,6 +54,9 @@ void processExpr(EvalState & state, const Strings & attrPaths,
else if (output == okJSON) {
printValueAsJSON(state, strict, vRes, v.determinePos(noPos), std::cout, context);
std::cout << std::endl;
} else if (output == okRaw) {
std::cout << *state.coerceToString(noPos, vRes, context, "while generating the nix-instantiate output");
std::cout << std::endl;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix eval --raw is even more raw, by not adding a trailing newline.

            writeFull(STDOUT_FILENO, *state->coerceToString(noPos, *v, context, "while generating the eval command output"));

I think in both commands, we should make the extra newline dependent on whether stdout is a tty, probably as a general rule to be implemented in the proposed (elsewhere) function that factors out the stopProgressBar() + writeFull(STDOUT... combination.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I see no reason why we couldn't stop the progress bar in the old CLI.
If we don't have one, stopping it should just be a no-op.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw: There's a logger->pause() (and a corresponding logger->resume() method that's marginally more generic than stopProgressBar (well, in practice it does the same thing, but it's more future-proof).

} else {
if (strict) state.forceValueDeep(vRes);
vRes.print(state.symbols, std::cout);
Expand Down Expand Up @@ -134,6 +137,8 @@ static int main_nix_instantiate(int argc, char * * argv)
outputKind = okXML;
else if (*arg == "--json")
outputKind = okJSON;
else if (*arg == "--raw")
outputKind = okRaw;
else if (*arg == "--no-location")
xmlOutputSourceLocation = false;
else if (*arg == "--strict")
Expand Down