nix icon indicating copy to clipboard operation
nix copied to clipboard

Allow `diff-closures` to output `json`

Open Pamplemousse opened this issue 1 year ago • 11 comments

Pamplemousse avatar Oct 31 '22 16:10 Pamplemousse

What does the JSON output look like?

edolstra avatar Oct 31 '22 17:10 edolstra

Here's an excerpt of what I can get with outputs/out/bin/nix --extra-experimental-features nix-command store diff-closures /run/current-system /nix/store/5ks2pk9n0lwmck32552ysjf1d7662pmv-nixos-system-foo-22.05.20221023.471d921

{
  "bash-interactive": {
    "after": "∅",
    "before": "∅",
    "sizeDelta": "+6384.3"
  },
  "bind": {
    "after": "9.18.7",
    "before": "9.18.3",
    "sizeDelta": "+44.8"
  },
  "blas": {
    "after": "∅",
    "before": "3",
    "sizeDelta": "-56241.8"
  },
  "chrootenv": {
    "after": "ε",
    "before": "∅",
    "sizeDelta": "+17.5"
  },
 ...
}

Pamplemousse avatar Nov 01 '22 08:11 Pamplemousse

    "after": "ε",
    "before": "∅",

Can we use null, empty string or something that everyone knows how to type on their keyboard?

SuperSandro2000 avatar Nov 01 '22 10:11 SuperSandro2000

Yeah, using null sounds good.

sizeDelta should just be a number, not a string, and should be the delta in bytes.

before and after should probably be versionBefore and versionAfter, to make clear what it's referring to.

It would be nice to include the before/after store paths that are being compared.

edolstra avatar Nov 01 '22 10:11 edolstra

Can we use null, empty string or something that everyone knows how to type on their keyboard?

I favored consistency and kept the symbols in use in the "regular" display.

Pamplemousse avatar Nov 01 '22 15:11 Pamplemousse

It would be nice to include the before/after store paths that are being compared.

I was just looking for a mean to exploit the data that is currently being rendered by diff-closures automatically, not necessarily try to "better" the output of the command.

Pamplemousse avatar Nov 01 '22 15:11 Pamplemousse

It would be cool to finish this! Nice to have JSON for all commands.

Ericson2314 avatar Jun 14 '23 19:06 Ericson2314

It would be cool to finish this!

I addressed the comments from the PR, either by updating the code, or by explaining why the display makes use of certain symbols.

I didn't get any extra feedback here, and have asked for some on Matrix months ago without any replies. As far as I can tell, this is "finished".

Pamplemousse avatar Jun 15 '23 07:06 Pamplemousse

I enqueued this on the project board to try to get some feedback from the rest of the team.

Ericson2314 avatar Jun 23 '23 11:06 Ericson2314

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-24-nix-team-meeting-minutes-75/31112/1

nixos-discourse avatar Jul 31 '23 07:07 nixos-discourse

When the derivation name does not strictly follow the name-version format, diff-closure usually displays wrong derivation name (or ""). For exemple when making custom intermediate derivations for my configs, adding a version doesn't really make sense, and adding a -0 or -unversioned seems like a workaround for nice display.

To help downstream users of this json, have you considered adding the Nix store paths for before/after in addition to only the version?

That would also allow doing more than just display the before/after versions and size delta, like using external diff tools on the paths to get more diff information.

bew avatar Jul 31 '23 08:07 bew