"hash mismatch in fixed-output derivation" issue with portmod

I was hoping to update Portmod to the latest release version 2.1.0 but have ran into a problem. Any ideas what would cause this?

I’m new to this and all I’ve done is change the main SHA265 and version number here: nixpkgs/default.nix at 884018a4fbe4d4096addf3dec0bfdb743b933b74 · 1MachineElf/nixpkgs · GitHub

Unfortunately, I cannot seem to build it properly. There is an error about an unexpected hash value for a derivation with name ending in portmod-rust-2.1.0-vendor.tar.gz. Here’s the error:

shrinking RPATHs of ELF executables and libraries in /nix/store/vyn3v2m1h97f7ci4n05f6gifyy412by2-portmod-rust-2.1.0-vendor.tar.gz
strip is /nix/store/4g5fidyk19akng9n91cql60ylrjq93s6-gcc-wrapper-10.3.0/bin/strip
patching script interpreter paths in /nix/store/vyn3v2m1h97f7ci4n05f6gifyy412by2-portmod-rust-2.1.0-vendor.tar.gz
checking for references to /build/ in /nix/store/vyn3v2m1h97f7ci4n05f6gifyy412by2-portmod-rust-2.1.0-vendor.tar.gz...
hash mismatch in fixed-output derivation '/nix/store/xmd699jbrps4m58n78v4z4qhciapf3y8-portmod-rust-2.1.0-vendor.tar.gz':
  wanted: sha256:1g9faqbqzh9nf71kgzdsn8ih83riyw13cbf8mz3qipv0d5k2225l
  got:    sha256:1cd8ycwh27ma9zmkcaw2xiv3v95qhdhs1nkmvq0qnjcnjhrcqiyw
cannot build derivation '/nix/store/vga44rn4vb8l0rsdf6l7bndlbam7iqzs-portmod-rust-2.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/d1h4nm819xm9g2fhk7kdwsxsc6amzc9b-portmod-2.1.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/d1h4nm819xm9g2fhk7kdwsxsc6amzc9b-portmod-2.1.0.drv' failed

Slightly edited full output below:

[me@x570-nixos:~/nixpkgs-portmod]$ nix-env -i portmod -f /home/evan/nixpkgs-portmod --show-trace
installing 'portmod-2.1.0'
these derivations will be built:
  /nix/store/s6gdqbjyvzq0g9mi99dw39k3r8ma4bq5-portmod-rust-2.1.0-vendor.tar.gz.drv
  /nix/store/vga44rn4vb8l0rsdf6l7bndlbam7iqzs-portmod-rust-2.1.0.drv
  /nix/store/d1h4nm819xm9g2fhk7kdwsxsc6amzc9b-portmod-2.1.0.drv
building '/nix/store/s6gdqbjyvzq0g9mi99dw39k3r8ma4bq5-portmod-rust-2.1.0-vendor.tar.gz.drv'...
unpacking sources
unpacking source archive /nix/store/261lz9jfhiv6csb56fdwqw059gq6sw9p-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
    Updating crates.io index
 Downloading crates ...
  Downloaded crossbeam-utils v0.8.5
  Downloaded fnv v1.0.7
  Downloaded hashbrown v0.11.2

...

  Downloaded no..m v6.2.1
  Downloaded ntapi v0.3.6
  Downloaded syn v1.0.75
  Downloaded winapi-i686-pc-windows-gnu v0.4.0
  Downloaded winapi-x86_64-pc-windows-gnu v0.4.0
   Vendoring Inflector v0.11.4 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/Inflector-0.11.4) to portmod-rust-2.1.0-vendor.tar.gz/Inflector
   Vendoring aho-corasick v0.7.15 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.15) to portmod-rust-2.1.0-vendor.tar.gz/aho-corasick
   Vendoring arc-swap v1.3.1 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/arc-swap-1.3.1) to portmod-rust-2.1.0-vendor.tar.gz/arc-swap
   Vendoring arrayref v0.3.6 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/arrayref-0.3.6) to portmod-rust-2.1.0-vendor.tar.gz/arrayref
   Vendoring arrayvec v0.5.2 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/arrayvec-0.5.2) to portmod-rust-2.1.0-vendor.tar.gz/arrayvec-0.5.2
   Vendoring arrayvec v0.7.1 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/arrayvec-0.7.1) to portmod-rust-2.1.0-vendor.tar.gz/arrayvec
   Vendoring autocfg v1.0.1 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/autocfg-1.0.1) to portmod-rust-2.1.0-vendor.tar.gz/autocfg
   Vendoring bitflags v1.3.2 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/bitflags-1.3.2) to portmod-rust-2.1.0-vendor.tar.gz/bitflags
   Vendoring bitvec v0.19.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/bitvec-0.19.5) to portmod-rust-2.1.0-vendor.tar.gz/bitvec
   Vendoring blake2 v0.9.1 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/blake2-0.9.1) to portmod-rust-2.1.0-vendor.tar.gz/blake2
   Vendoring blake3 v1.0.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/blake3-1.0.0) to portmod-rust-2.1.0-vendor.tar.gz/blake3
   Vendoring block-buffer v0.9.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/block-buffer-0.9.0) to portmod-rust-2.1.0-vendor.tar.gz/block-buffer
   Vendoring bstr v0.2.15 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/bstr-0.2.15) to portmod-rust-2.1.0-vendor.tar.gz/bstr
   Vendoring bumpalo v3.7.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/bumpalo-3.7.0) to portmod-rust-2.1.0-vendor.tar.gz/bumpalo
   Vendoring cassowary v0.3.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/cassowary-0.3.0) to portmod-rust-2.1.0-vendor.tar.gz/cassowary
   Vendoring cc v1.0.69 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/cc-1.0.69) to portmod-rust-2.1.0-vendor.tar.gz/cc
   Vendoring cfg-if v1.0.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/cfg-if-1.0.0) to portmod-rust-2.1.0-vendor.tar.gz/cfg-if
   Vendoring constant_time_eq v0.1.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/constant_time_eq-0.1.5) to portmod-rust-2.1.0-vendor.tar.gz/constant_time_eq
   Vendoring convert_case v0.4.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/convert_case-0.4.0) to portmod-rust-2.1.0-vendor.tar.gz/convert_case
   Vendoring cpufeatures v0.1.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/cpufeatures-0.1.5) to portmod-rust-2.1.0-vendor.tar.gz/cpufeatures
   Vendoring crossbeam-channel v0.5.1 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/crossbeam-channel-0.5.1) to portmod-rust-2.1.0-vendor.tar.gz/crossbeam-channel
   Vendoring crossbeam-deque v0.8.1 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/crossbeam-deque-0.8.1) to portmod-rust-2.1.0-vendor.tar.gz/crossbeam-deque
   Vendoring crossbeam-epoch v0.9.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/crossbeam-epoch-0.9.5) to portmod-rust-2.1.0-vendor.tar.gz/crossbeam-epoch
   Vendoring crossbeam-utils v0.8.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.5) to portmod-rust-2.1.0-vendor.tar.gz/crossbeam-utils
   Vendoring crossterm v0.20.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/crossterm-0.20.0) to portmod-rust-2.1.0-vendor.tar.gz/crossterm
   Vendoring crossterm_winapi v0.8.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/crossterm_winapi-0.8.0) to portmod-rust-2.1.0-vendor.tar.gz/crossterm_winapi

...

   Vendoring wasm-bindgen-backend v0.2.76 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-backend-0.2.76) to portmod-rust-2.1.0-vendor.tar.gz/wasm-bindgen-backend
   Vendoring wasm-bindgen-macro v0.2.76 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-macro-0.2.76) to portmod-rust-2.1.0-vendor.tar.gz/wasm-bindgen-macro
   Vendoring wasm-bindgen-macro-support v0.2.76 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-macro-support-0.2.76) to portmod-rust-2.1.0-vendor.tar.gz/wasm-bindgen-macro-support
   Vendoring wasm-bindgen-shared v0.2.76 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-shared-0.2.76) to portmod-rust-2.1.0-vendor.tar.gz/wasm-bindgen-shared
   Vendoring winapi v0.3.9 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.9) to portmod-rust-2.1.0-vendor.tar.gz/winapi
   Vendoring winapi-i686-pc-windows-gnu v0.4.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/winapi-i686-pc-windows-gnu-0.4.0) to portmod-rust-2.1.0-vendor.tar.gz/winapi-i686-pc-windows-gnu
   Vendoring winapi-util v0.1.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/winapi-util-0.1.5) to portmod-rust-2.1.0-vendor.tar.gz/winapi-util
   Vendoring winapi-x86_64-pc-windows-gnu v0.4.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0) to portmod-rust-2.1.0-vendor.tar.gz/winapi-x86_64-pc-windows-gnu
   Vendoring wyz v0.2.0 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/wyz-0.2.0) to portmod-rust-2.1.0-vendor.tar.gz/wyz
   Vendoring yaml-rust v0.4.5 (/build/source/cargo-home.qFI/registry/src/github.com-1ecc6299db9ec823/yaml-rust-0.4.5) to portmod-rust-2.1.0-vendor.tar.gz/yaml-rust
To use vendored sources, add this to your .cargo/config.toml for this project:

installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/vyn3v2m1h97f7ci4n05f6gifyy412by2-portmod-rust-2.1.0-vendor.tar.gz
strip is /nix/store/4g5fidyk19akng9n91cql60ylrjq93s6-gcc-wrapper-10.3.0/bin/strip
patching script interpreter paths in /nix/store/vyn3v2m1h97f7ci4n05f6gifyy412by2-portmod-rust-2.1.0-vendor.tar.gz
checking for references to /build/ in /nix/store/vyn3v2m1h97f7ci4n05f6gifyy412by2-portmod-rust-2.1.0-vendor.tar.gz...
hash mismatch in fixed-output derivation '/nix/store/xmd699jbrps4m58n78v4z4qhciapf3y8-portmod-rust-2.1.0-vendor.tar.gz':
  wanted: sha256:1g9faqbqzh9nf71kgzdsn8ih83riyw13cbf8mz3qipv0d5k2225l
  got:    sha256:1cd8ycwh27ma9zmkcaw2xiv3v95qhdhs1nkmvq0qnjcnjhrcqiyw
cannot build derivation '/nix/store/vga44rn4vb8l0rsdf6l7bndlbam7iqzs-portmod-rust-2.1.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/d1h4nm819xm9g2fhk7kdwsxsc6amzc9b-portmod-2.1.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/d1h4nm819xm9g2fhk7kdwsxsc6amzc9b-portmod-2.1.0.drv' failed

You changed the checksum of the source of the portmod-rust derivation.

But since the main derivation is also a fixed-output derivation (FOD), you need to update its cargoHash attribute too.

You can just use the hash Nix calculated here

got: sha256:1cd8ycwh27ma9zmkcaw2xiv3v95qhdhs1nkmvq0qnjcnjhrcqiyw

to replace the old cargoHash value.

1 Like

Thanks for your reply. Maybe you can clarify this for me. Where does that expected value come from? In the default.nix file, the cargoHansh value is sha256-tAghZmlg34jHr8gtNgL3MQ8EI7K6/TfDcTbBjxdWLr0=, which matches neither the wanted or got values in the error.

EDIT: Ok. I see what you meant. I switched cargoHash to cargoSha256 and was able to get past the issue. I found the info I was looking for: NixOS - Nixpkgs 21.11 manual