Fake SHA256 in a Nix derivation
Posted on in Nix
Discovering the SHA256 hash for a derivation is a chore.
One approach is to fake the hash with zeroes.
sha256 = "0000000000000000000000000000000000000000000000000000";
This induces nix-build to throw an error containing the correct hash.
However, even the fake hash has to be correct, i.e., needs to have the right number of zeroes in it. Otherwise, nix-build throws an error about the hash being invalid instead of being incorrect. This error does not contain the correct hash.
Thankfully, Nix already binds the fake hash value to a variable lib.fakeSha256
.
sha256 = lib.fakeSha256;
Thanks to paulyoung for this tip.
I found a more memorable variable lib.fakeHash
.