SHA256 from package.nix doesn't match on zip via fetchurl on github?

How is this possible?

First I built the package via nix-env -iA package

It wasn’t as it should be. At all (not even for Linux). So I found the .nix file, followed the URL to github, downloaded the linux zip … SHA256 doesn’t match what’s in the .nix file, and it’s for another operating system again.

So I start thinking that maybe it’s not following the nix file that I’m looking at? So, time to do things manually…

I tried building the package via:
nix-build -E 'with import <nixpkgs> {}; callPackage ./package.nix {}'

(I originally wanted to do this via my config file, but it’s an unstable package … which I can’t seem to figure out)

Edit: I 100% understand how I could get the wrong file from github.
What I don’t understand is how NixOS is accepting receiving the wrong file when it’s following the package.nix? Since the hashes aren’t matching… it should be rejecting it, right?

Packages using fetchFromGithub, which yours presumably is using, don’t base their source hashes on the archive itself. They download the archive, extract it, then hash the contents of the archive. This is done because archives on GitHub are not guaranteed to be stable. They can change while keeping the contents the same.

2 Likes