I see the bindgen crate constantly rebuilding

If you are using rustPlatform.bindgenHook it is worth noting that it will propagate NIX_CFLAGS_COMPILE via BINDGEN_EXTRA_CLANG_ARGS.

In order to support reproducible builds, this build hook will add -frandom-seed=... to NIX_CFLAGS_COMPILE based on the current derivation's hash.

Since dependencies are built in a separate derivation as the main package, each derivation essentially gets a different value for -frandom-seed. The bindgen crate will observe this change and rebuild itself.

A workaround for this is to set NIX_OUTPATH_USED_AS_RANDOM_SEED to any arbitrary 10 character string for all derivations which share artifacts together.

buildPackage {
  # other attributes omitted