Check multiple configurations for differences

Hi all,
So I am tearing my hair out with an application which works (seemingly randomly) on one machine, and fine on 2 others (being AMD/AMDGPU, Intel/Nvidia and raspi).

The configs are very similar (of course hardware elements differ), spread over multiple imported files - is there a “compare” so that I can determine the differences? As the order may well be different, a file compare doesn’t help much. Even a “this config has these extra derivations (or even config lines)” would be really helpful.

At some point I will get to having a common config with options which will make this easier (and even flakes perhaps…), but as I haven’t yet got my head around those complexities, I was hoping for some more “debug” options.

TIA

You could try this in your terminal where $CONFIG_A and $CONFIG_B are the two configurations you want to compare.

nixos-rebuild build $CONFIG_A
mv result config_a
nixos-rebuild build $CONFIG_B
mv result config_b
nix store diff-closures config_a config_b

@olmokramer thanks for the pointer to this - I didn’t know this existed! Just having it to compare changes on the same machine is awesome…

Yeah it’s pretty neat :slight_smile: also took me a while to figure that out.

Sorry for more (and drifting off topic) but are there more nix commands and where might I find them?

As an example, I have a EOL package (Electron) but I don’t remember any of my other apps needing it (so therefore don’t know how to sort it).

TIA

See nix-store and nix store for more information on how to query or update the store. There’s also nix why-depends which is pretty useful and may tell you why your config depends on some package. Building on my previous example, you could try nix why-depends ./config_a /nix/store/<hash>-electron-<version>.

2 Likes

Thanks…although I am now in the realm of more power, and more confusion. I think I might take a lie down before working out hoqw to use all these new commands! :sweat_smile:

1 Like

diffoscope and nix-diff are pretty handy

Yeah there’s a lot to take in and it can be overwhelming at times. Take your time and try to learn in small steps, not everything at once. A messy configuration that works is infinitely better than one that doesn’t. And if you have more questions, the community has generally been really helpful.