I’m using a flake (with crate2nix) to manage a Rust project which needs the HDF5 libray. When trying to upgrade the flake from nixos 22.11 to 23.05 I get the following error, when compiling the Rust code:
error: failed to run custom build command for `hdf5-sys v0.8.1`
Caused by:
process didn't exit successfully: `/tmp/bump-nix/target/debug/build/hdf5-sys-af0ab5be5860baa3/build-script-build` (exit status: 101)
--- stdout
Setting HDF5 root from environment variable:
HDF5_DIR = "/nix/store/lixvnqz0s5cylwl8grxlas3gxl7hb6s9-hdf5"
Custom HDF5_DIR provided; rpath can be set via:
RUSTFLAGS="-C link-args=-Wl,-rpath,/nix/store/lixvnqz0s5cylwl8grxlas3gxl7hb6s9-hdf5/lib"
Parsing HDF5 config from:
"/nix/store/lixvnqz0s5cylwl8grxlas3gxl7hb6s9-hdf5/include/H5pubconf.h"
--- stderr
thread 'main' panicked at 'Invalid H5_VERSION: "1.14.0"', /home/me/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hdf5-sys-0.8.1/build.rs:200:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: command `/nix/store/3zgxqy978lcdgxldfpz0gggivlamhmrv-cargo-1.70.0-x86_64-unknown-linux-gnu/bin/cargo test --no-run --message-format json-render-diagnostics --workspace --exclude bindings` exited with code 101
error: Recipe `test-rust-pure` failed on line 9 with exit code 101
error: Recipe `test-rust` failed on line 6 with exit code 101
The part about ‘Setting HDF5 root from environment variable’ relates to this
Naively following the advice about setting rpath doesn’t seem to improve the situation.
I don’t know whether the former is just a warning and the only fatal part is the ‘Invalid H5_VERSION: “1.14.0”’ panic. I see that nixpkgs 23.05 has hdf5 version 1.14.0, while 22.11 has 1.12.2. Does this mean that there is an incompatibility between what the hdf5 crate expects and nixpkgs 23.05 provides?
Do you have any hints about how to get past this problem?
Thank you so much for the code sample. This is the sort of thing that I understand in principle, but would take me a prohibitive amount of time to sort out the details in practice.
One thing that has me stymied: I get the error
error: hash mismatch in file downloaded from 'https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.bz2':
specified: sha256:181bdh8hp7v9xqwcby3lknr92lxlicc2hqscba3f5nhf8lrr9rz4
got: sha256:1zlawdzb0gsvcxif14fwr5ap2gk4b6j02wirr2hcx8hkcbivp20s
while the code that I copy-pasted from your example contains
The URLs match, but the specified (or even the got) SHA in the error message does not match the one specified in the code.
Oh … your code did not qualify fetchurl and I guessed that it comes from builtins, which is what resulted in the above error message. But there is also a fetchurl in nixpkgs. If I use that one instead, I now get
that is to say, the specified SHA in the error message now does match the one specified in the source.
This leaves me with two puzzles:
WTF is the difference between builtins.fetchurl and nixpkgs.fetchurl? OK, I’ve found this, but I don’t have time to ruminate on it and to try to digest its meaning. It’s tempting to conclude that it’s an evil practical joke. These sorts of things certainly don’t help wider adoption of Nix.
If the URLs match exactly, but the SHAs differ, I infer that they update the tarball at that location (or a miscreant is up to something nefarious), and if they do that then this derivation is going to be running into this problem repeatedly. If so, is there a workaround?