Hash mismatch importing path, nix binary cache broken?

Hello,

when i try to build my nix file for a vm image i get the following error:

error: hash mismatch importing path '/nix/store/r26vcc9843r9x631swg9shcrc37a6ccz-ld.so';
         specified: sha256:1jrc8fsimzn5y03adxfjh5wy60jrd5viqfyyzc6s31qnyrfal1da
         got:       sha256:1197fxmwvnl5hjdmkfhif3rqp0h2pd86h0j3p6d7aw9qwihvc1fv
copying path '/nix/store/q85b2a583s2hx3qsyq58ynszxljnlvhq-libICE-1.0.10' to 'local'...
copying path '/nix/store/vbf6jqdxvjvplcqk0kaz1pav1vljv7iw-libXau-1.0.9' to 'local'...
error: build of '/nix/store/886xgfmyw1lsvi4rsj9xxpqg9lbzj0ff-nixos-system-nixos-23.05.4930.f741f8a83991' failed
error: builder for '/nix/store/qbrpy9kmv9r67j0zv5q153sw6x2ww4d3-nixos-disk-image.drv' failed with exit code 1;
       last 10 log lines:
       > copying path '/nix/store/lgn07zdrnmfrvvn9ck5z941dynsgfz1i-json-c-0.16' to 'local'...
       > copying path '/nix/store/50x70gjr65lq673w73bmvd8r4fjvq13w-keyutils-1.6.3-lib' to 'local'...
       > copying path '/nix/store/hjax7sqq9vicnn3g614kijcryh11qarv-lcms2-2.15' to 'local'...
       > copying path '/nix/store/r26vcc9843r9x631swg9shcrc37a6ccz-ld.so' to 'local'...
       > error: hash mismatch importing path '/nix/store/r26vcc9843r9x631swg9shcrc37a6ccz-ld.so';
       >          specified: sha256:1jrc8fsimzn5y03adxfjh5wy60jrd5viqfyyzc6s31qnyrfal1da
       >          got:       sha256:1197fxmwvnl5hjdmkfhif3rqp0h2pd86h0j3p6d7aw9qwihvc1fv
       > copying path '/nix/store/q85b2a583s2hx3qsyq58ynszxljnlvhq-libICE-1.0.10' to 'local'...
       > copying path '/nix/store/vbf6jqdxvjvplcqk0kaz1pav1vljv7iw-libXau-1.0.9' to 'local'...
       > error: build of '/nix/store/886xgfmyw1lsvi4rsj9xxpqg9lbzj0ff-nixos-system-nixos-23.05.4930.f741f8a83991' failed
       For full logs, run 'nix-store -l /nix/store/qbrpy9kmv9r67j0zv5q153sw6x2ww4d3-nixos-disk-image.drv'.

the file it self worked a few days ago on a other computer. Therefore i think, the hash in the nix binary cache is broken. The package causing the error is: programs.nix-ld.enable = true; and Iā€™m using the nixos-23.05 channel.
Is there anything I can do e.g. build the ld.so from scratch?

Thank you all in advance

can we see your ā€˜nix fileā€™, we can the get ā€˜producerā€™ (thanks tom).

what substitutes do you have?

are you using flakes?

I have uploaded the code here:

Iā€™m not using flakes and to build the code i use the following command in WSL:
nix-build vbox.nix

Hum, maybe verify and restore that path? Itā€™s very unlikely the public cache is broken, lots more people would complain about this, and nix would not have even dowloaded that artifact in the first place, but your local copy may have flipped a bit or two somehow.

I tried that, but got the same issue, then I completely reinstalled WSL and Nix and still got the error. Therefore, I think that the problem is with the version of the package in the cache.

I was able to nix build that path so the cache shouldnā€™t be broken.

The reason this surfaces during a closure copy is that Nix assembles back the NAR file to send over the wire, and compares its checksum with the one it got from cache.nixos.org (which is recorded in /nix/var/nix/db/db.sqlite). And because of the disk corruption, the assembled NAR ends up with different content.

Maybe WSL has something to do with it

/nix/store/r26vcc9843r9x631swg9shcrc37a6ccz-ld.so is a symlink to /nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/ld-linux-x86-64.so.2

Can you build /nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/ld-linux-x86-64.so.2

fallback could work around it but diffing the files would be interesting nix.conf - Nix Reference Manual

2 Likes

I can confirm that it worked and works for me with nix 2.18.1, but breaks with 2.19.1 with Archlinux ā€œbare-metalā€.
To reproduce :

# Install nix 2.18.1, restart daemon, then
sudo nix-store --repair-path /nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/ld-linux-x86-64.so.2 /nix/store/r26vcc9843r9x631swg9shcrc37a6ccz-ld.so
(cd base-config && nix-build qcow.nix) # works fine
# Install nix 2.19.1, restart daemon, then
sudo nix-store --repair-path /nix/store/whypqfa83z4bsn43n4byvmw80n4mg3r8-glibc-2.37-45/lib/ld-linux-x86-64.so.2 /nix/store/r26vcc9843r9x631swg9shcrc37a6ccz-ld.so
(cd base-config && nix-build qcow.nix) # breaks with the hash mismatch

I have another reproduction of this. I have a VM image that I built with Nix 2.18, that doesnā€™t work when I try to build it using 2.19.

Is there a Nix issue with this? What have people been doing to workaround? Iā€™m downgrading to Nix 2.18, but obviously, that is a time limited strategy.

In my case, I disabled documention in the configuration.nix file and the build was successful again, using Nix 2.20.1:

  documentation = {
    enable = false;
  };
1 Like