Cannot request JSON
output for CLI command: nix store diff-closures
#532
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#532
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Is your feature request related to a problem? Please describe.
I wanted to parse the output of
nix store diff-closures
and discovered this command doesn't accept the--json
flag accepted by many other Nix commands.According to CppNix's manual entry on CLI guidelines:
This is a good instance to have machine-readable output.
Describe the solution you'd like
Support the
--json
flag in thenix store diff-closures
command.Not sure what other commands are missing this, but it might be worth adding support for the
--json
flag in other similar commands that may be missing it.Describe alternatives you've considered
--debug
,--log-format internal-json
,--print-build-logs
,--verbosity
.pkgs.nvd
to see if it was using aJSON
representation anywhere before formatting forstdout
.stdout
intoJSON
. However, it would be much easier to get theJSON
first then format that forstdout
rather than in the reverse direction.Additional context
Many other commands support
JSON
output, and it is useful for building tooling around the Nix CLI. Closure diffs are particularly useful for parsing since that can be used to develop insights about changes and updates.In principle I agree that we should have structured output, but I don't think that nix store diff-closures is a terribly well designed command to begin with: it is trying to parse some meaning out of store path names (which is at best fragile) in order to determine whether two derivations are the same package. This is the same mistake made by nix-env (that makes
nix-env -u
unusably broken); though there is not that much that can be done to do better than that besides pulling stuff out of parsing derivations (kind of an even worse layering violation).I also think that even if we have json output, it is not necessarily going to be valuable, considering what https://github.com/Gabriella439/nix-diff does.
Useful closure diff info, to me, involves representing the DAG/tree nature of the data as to why a package got into there. That structure information ought to be put into the JSON as well.
For your current use case, you might want to consider
nix path-info --recursive --size --closure-size --json
then unifying the store path names yourself or using nix-diff (at least it's not hard to do just as well as lix which currently uses a regex).