To reproduce this, try the following in nix repl <nixpkgs>
fetchurl { url=https://crates.io/api/v1/crates/arrayvec/0.4.10/download;sha256="92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"; }
versus
fetchTarball {url=https://crates.io/api/v1/crates/arrayvec/0.4.10/download;sha256="92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71";}
fetchurl gets a SHA256 that is consistent with the hash of the actual file, but fetchTarball does not.
This is normal, if you look at the result of both builds you'll see that they are different. fetchurl just downloads a file while fetchTarball downloads and unpacks it first, in which case the unpacked content is hashed.
The different hashing modes are described in a bit more detail herehttps://nixos.org/nix/manual/#fixed-output-drvs.
You can get the "unpacked" hash using nix-prefetch-url --unpack BTW.
Most helpful comment
This is normal, if you look at the result of both builds you'll see that they are different. fetchurl just downloads a file while fetchTarball downloads and unpacks it first, in which case the unpacked content is hashed.
The different hashing modes are described in a bit more detail herehttps://nixos.org/nix/manual/#fixed-output-drvs.