Why wouldn't the sha256 hash change when fetching from a different URL (when updating a package)?

Thanks! Haven’t heard of this function yet.

Thanks! I just found it in the Nix manual (archive) but I also haven’t remembered it being there to be honest.

Again, this is what I remembered as well, until a couple days ago I had to update another package, and it didn’t work (neither did using a random value). I found the 52 zeroes solution suggested by a Stackoverflow comment.

$ nix-build -A docbook5
error: hash '' has wrong length for hash type 'sha256'

$ nix-build -A docbook5
error: hash 'random' has wrong length for hash type 'sha256'

$ nix-build -A docbook5
error: invalid base-32 hash '7777777777777777777777777777777777777777777777777777'

$ nix-build -A docbook5
these derivations will be built:
  /nix/store/6x7fbvxhqr4pmcz48fzamavfyhhgmn1c-docbook-5.0.1.zip.drv
  /nix/store/9a9cd090fzwq4g03mbghphsq68f3n142-docbook5-5.0.1.drv
building '/nix/store/6x7fbvxhqr4pmcz48fzamavfyhhgmn1c-docbook-5.0.1.zip.drv'...

trying http://www.docbook.org/xml/5.0.1/docbook-5.0.1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    67  100    67    0     0    172      0 --:--:-- --:--:-- --:--:--   172
100    63  100    63    0     0    116      0 --:--:-- --:--:-- --:--:--   116
100  816k  100  816k    0     0   535k      0  0:00:01  0:00:01 --:--:-- 1399k
hash mismatch in fixed-output derivation '/nix/store/zzp8gm0h65ln7b594b8h3iyismr22s83-docbook-5.0.1.zip':
  wanted: sha256:0000000000000000000000000000000000000000000000000000
  got:    sha256:1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs
cannot build derivation '/nix/store/9a9cd090fzwq4g03mbghphsq68f3n142-docbook5-5.0.1.drv': 1 dependencies couldn't be built
error: build of '/nix/store/9a9cd090fzwq4g03mbghphsq68f3n142-docbook5-5.0.1.drv' failed

Probably the nix-prefetch-url method is the best (but I’ll probably forget it…).

Would you expand on this? I may have been misusing the term name then, but the output path was certainly different, and the name of the derivation can be generated from pname and version since RFC-35 (PR). Then again, whenever I get confident that I understand something NIx-related, I quickly get a reality check…

Is this something akin to RFC-35?