Cannot repair path: Invalid exchange

Running sudo nix-store --verify --check-contents --repair I get the following error:

reading the Nix store…
checking path existence…
checking link hashes…
checking store hashes…
error: getting status of “/nix/store/4l8s3x8pzim4vdwdvpls8mwcaxllik4s-source/pkgs/by-name/po/polkit_gnome”: Invalid exchange
path ‘/nix/store/8m7rjx30w2k114q17c8qfig14gj3f43r-source’ was modified! expected hash ‘sha256:0f94v16ih89llrjj7kglr9c5r3klxsgcrmh51x8khjqs1iqal3hf’, got ‘sha256:16q62ih2lygld9c0v19xjplqlc5brh0407bffq0crgbbjjfsdshz’
error: cannot repair path ‘/nix/store/8m7rjx30w2k114q17c8qfig14gj3f43r-source’

What do I do now?

If you are lucky doing a sudo nix-collect-garbage -d (and also doing it with -u for each user that might have a profile), deleting all the result links across all users, and maybe deleting other roots that are not covered by nix-collect-garbage, then another repair might suffice.

If you are less lucky, you have to reboot and redo the dance.

If the problem persists after that, it is time to get your rescuedisk/nixos-installer ready to boot into it, delete the hosts nix store and then reinstall from your config.

Details on the latter depend on whether you use channels or flakes.

2 Likes