nix-cli: Add --json --pretty / --no-pretty#12652
Conversation
Default: istty(stdout) This refactors `nix develop` internals a bit to use the `json` type more. The assertion now operates in the in-memory json instead of re-parsing it. While this is technically a weaker guarantee, we should be able to rely on the library to get this right. It's its most essential purpose.
crertel
left a comment
There was a problem hiding this comment.
LGTM, couple of teeny spots to clean if desired.
|
|
||
| This option is only effective when `--json` is also specified. | ||
| )", | ||
| //.category = commonArgsCategory, |
There was a problem hiding this comment.
| //.category = commonArgsCategory, |
Remove deadcode.
|
|
||
| See `--pretty`. | ||
| )", | ||
| //.category = commonArgsCategory, |
There was a problem hiding this comment.
| //.category = commonArgsCategory, |
Remove deadcode.
Some four years old; time to go
There was a problem hiding this comment.
LGTM!
Non-blocking question: I noticed that the logger invocations seem to have been centralized into how printJSON works now (if I read it correctly). Are we ever going to want to do anything file-specific or class-specific with the loggers, or is it okay that it seems like they all kinda share that implicitly now (or am I misunderstanding how logging works in nix)?
Like log4j style logging? Nix'slogging is a bit simpler and more user focused than developer focused. |
|
Thank you @crertel for the review! |
Ah, okay, thank you for the information! I wasn't sure, hence my question. Now I know. :) |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nix-2-29-0-released/64609/1 |
nix derivation shownot a special caseScripts are mostly unaffected because there, stdout will be a file or a pipe, not a terminal, so they get the old behavior.
(Of course scripts can be constructed that create terminals etc, as I did in the test, but taking that into account would be disproportionate.)
This refactors
nix developinternals a bit to use thejsontype more. The assertion now operates in the in-memory json instead of re-parsing it. While this is technically a weaker guarantee, we should be able to rely on the library to get this right. It's its most essential purpose.Motivation
Fix a repeating papercut.
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.