Gabriella439 / nix-diff

Explain why two Nix derivations differ
BSD 3-Clause "New" or "Revised" License
340 stars 18 forks source link

If an environment diff looks like json, use a json differ like jd #52

Open blaggacao opened 2 years ago

blaggacao commented 2 years ago

Sometimes a environment diff is actual plain json, diffed on one big single row. As a result an entire screen is coloured red/green without really helpful semantics. Even the --character-oriented is not really of great help at times (when the diff is a little bigger).

It might be possible to use something like https://github.com/josephburnett/jd to make the result more intelligible.

Since these tools are no haskell, a good way would be to optionally write files with old/new environments to disk, it then becomes trivial to do the semantic diffing by hand.

blaggacao commented 2 years ago

I was able to copy chunks manually together from the output, but that's rather brittle.

Gabriella439 commented 2 years ago

Yeah, we run into this same issue at work, too where the diff fares poorly on large JSON files. The tool can probably auto-detect JSON and use a more intelligent diff for that case

blaggacao commented 2 years ago

A colleague just hinted me at https://github.com/jeffkaufman/icdiff -- which I happily forward really just for general knowledge & inspiration in the context of this issue.