In my looking into nixos-facter (well, actually nixos-facter-modules) I have replaced my hardware related config values with usage of facter and then wanted to observe the differences between the original system and the new one. That is my current motivation for being able to diff module system configs, but this is likely a common desire for many different reasons methinks.
If I know my Nix well enough, there are three primary lenses to observe changes between two configurations:
- the evaluated config value
- some or other derivation that is included in that value
- realized store paths of above mentioned derivation
For number two, nix-diff has been serving me well. Thank you @Gabriel439.
For number three, well, it’s arbitrary files, whatever they are, so diff
works. But, of course, store paths have dependencies and nix-tree has been doing great work there for me. Thank you @utdemir.
But I’ve found myself wanting to know what config values are different between two configs. And I’m not sure how to achieve that. I tried the following in a repl:
:p nixosConfigurations.someConfig.config
But that does not end well. Or at all. I killed it before it consumed all my memory. Apparently, at least in a NixOS configuration (probably not just that specific one) that value includes a number of derivation values which make this approach impractical.
But in theory, I suppose this value could be filtered and then serialized to JSON and then diffed. I’m sure that some of us are expert enough to see into the future of such an implementation and shed light on it here, if they be so kind.
Mentioning Feature Request: Diffing NixOS systems · Issue #190033 · NixOS/nixpkgs · GitHub.