output path ‘/nix/store/i1xf3x515ncsrpxlrda23z95r8xa3j37-source’ has r:sha256 hash ‘0xv8fm67p2wkkv86v68hxx5fkb7lm906cr5v8hl6bf2hcfhx94yi’ when ‘43aa7e99dc9a476199746398a1478f4346d67f28adbe1e6a2633f7b19eaca2d7’ was expected
But why?
I get this sum with command sha256sum path_to_archive.tar.gz.
Either nix-hash for files outside of nix store or nix-prefetch-url '<nixpkgs>' -A hello.src for nixpkgs attributes or nix-prefetch-url "http://example.com/file" for urls.
The reason for the mismatch in this case is that Nix is computing the hash of the archive's contents not the archive itself.
... as /nix/store/i1xf3x515ncsrpxlrda23z95r8xa3j37-source is not an archive but a directory tree.
nix-prefetch-url --type sha256 --unpack https://github.com/path/to/archive.tar.gz works fine.
Thanks you so much.
Most helpful comment
The reason for the mismatch in this case is that Nix is computing the hash of the archive's contents not the archive itself.