Describe the bug
Title
nix build of the in-repo flake fails on release tags since v2.4.x (vergen NotPresent + missing libffi/libxml2 at link time)
Steps to reproduce
Description
The flake shipped in this repository no longer builds from a release tag tarball. Building v2.3.0 with Nix works, but v2.4.1 fails for two independent reasons. Both appear to be regressions introduced in the 2.4.x cycle and both only show up in environments without a .git directory and with a hermetic dependency set — i.e. exactly what nix build produces. main currently has the same flake.nix and build.rs, so this is still unfixed as of today.
Reproduction
nix build github:paradigmxyz/reth/v2.4.1#reth
(Also reproducible via a flake input pinned to the tag; same failures.)
Failure 1: vergen hard-fails without a git repository
crates/node/core/build.rs reads the git-derived variables with env::var(...)?:
let sha = env::var("VERGEN_GIT_SHA")?;
Nix fetches the tag as a tarball, so there is no .git. With the vergen version used up to v2.3.0, the emitter still populated the VERGEN_GIT_* variables with placeholder values when git information was unavailable, so the build script succeeded (with warnings). After the vergen bump in 2.4.x (BuildBuilder::default() → Build::builder() style API), the variables are simply not set when git is missing, and the build script aborts:
warning: reth-node-core@2.4.1: could not find repository at '.../crates/node/core'; class=Repository (6); code=NotFound (-3)
warning: reth-node-core@2.4.1: Unable to set VERGEN_GIT_DESCRIBE
warning: reth-node-core@2.4.1: Unable to set VERGEN_GIT_SHA
warning: reth-node-core@2.4.1: Unable to set VERGEN_GIT_DIRTY
error: failed to run custom build command for `reth-node-core v2.4.1`
...
--- stderr
Error: NotPresent
Workaround that confirms the diagnosis: setting VERGEN_DEFAULT_ON_ERROR=true (or pre-seeding VERGEN_GIT_SHA / VERGEN_GIT_DIRTY / VERGEN_GIT_DESCRIBE in the build environment) gets past this stage.
Suggested fix: make build.rs tolerate missing git info (fall back to defaults instead of ? on env::var), or set VERGEN_DEFAULT_ON_ERROR / provide the values inside the flake derivation. This would also fix any other from-tarball packaging (not just Nix).
Failure 2: link error — mold: fatal: library not found: ffi
With the vergen issue worked around, the build now compiles the entire workspace and fails at the final link of the reth binary:
error: linking with '.../clang' failed: exit status: 1
= note: mold: fatal: library not found: ffi
The final link line contains -lffi and -lxml2, pulled in via the statically linked LLVM (llvm-sys / revmc-llvm, new in the 2.4.x dependency tree together with the withLlvm22 overlay added to flake.nix). The flake adds llvm.dev / llvm.lib to the build, but not libffi and libxml2, so in the hermetic Nix build sandbox the linker cannot find them.
Workaround that confirms the diagnosis: adding libffi and libxml2 to buildInputs of the reth derivation makes the build succeed:
buildInputs = old.buildInputs or [] ++ [ pkgs.libffi pkgs.libxml2 ];
Suggested fix: add pkgs.libffi and pkgs.libxml2 to buildInputs in the withLlvm22 override (or wherever the LLVM link deps are declared) in flake.nix.
Full workaround used locally
For reference, this overrideAttrs on packages.<system>.reth produces a working v2.4.1 build:
(reth.packages.${system}.reth).overrideAttrs (old: {
# Failure 1
VERGEN_GIT_SHA = "8eb210175687c9f0c889a3b6795c16781d830e3a"; # commit of tag v2.4.1
VERGEN_GIT_DIRTY = "false";
VERGEN_GIT_DESCRIBE = "v2.4.1";
VERGEN_DEFAULT_ON_ERROR = "true";
# Failure 2
buildInputs = (old.buildInputs or []) ++ [ pkgs.libffi pkgs.libxml2 ];
})
Environment
- NixOS (nixos-unstable), x86_64-linux
- Building via the repo's own
flake.nix at tag v2.4.1
v2.3.0 builds fine from the same setup
Happy to open a PR for either fix if that helps.
Node logs
Platform(s)
Linux (x86)
Container Type
Not running in a container
What version/commit are you on?
v2.4.1 8eb2101
What database version are you on?
database version: 2
Which chain / network are you on?
ethereum mainnet
What type of node are you running?
Full via --full flag
What prune config do you use, if any?
No response
If you've built Reth from source, provide the full command you used
No response
Code of Conduct
Describe the bug
Title
nix buildof the in-repo flake fails on release tags since v2.4.x (vergenNotPresent+ missinglibffi/libxml2at link time)Steps to reproduce
Description
The flake shipped in this repository no longer builds from a release tag tarball. Building
v2.3.0with Nix works, butv2.4.1fails for two independent reasons. Both appear to be regressions introduced in the 2.4.x cycle and both only show up in environments without a.gitdirectory and with a hermetic dependency set — i.e. exactly whatnix buildproduces.maincurrently has the sameflake.nixandbuild.rs, so this is still unfixed as of today.Reproduction
(Also reproducible via a flake input pinned to the tag; same failures.)
Failure 1:
vergenhard-fails without a git repositorycrates/node/core/build.rsreads the git-derived variables withenv::var(...)?:Nix fetches the tag as a tarball, so there is no
.git. With the vergen version used up to v2.3.0, the emitter still populated theVERGEN_GIT_*variables with placeholder values when git information was unavailable, so the build script succeeded (with warnings). After the vergen bump in 2.4.x (BuildBuilder::default()→Build::builder()style API), the variables are simply not set when git is missing, and the build script aborts:Workaround that confirms the diagnosis: setting
VERGEN_DEFAULT_ON_ERROR=true(or pre-seedingVERGEN_GIT_SHA/VERGEN_GIT_DIRTY/VERGEN_GIT_DESCRIBEin the build environment) gets past this stage.Suggested fix: make
build.rstolerate missing git info (fall back to defaults instead of?onenv::var), or setVERGEN_DEFAULT_ON_ERROR/ provide the values inside the flake derivation. This would also fix any other from-tarball packaging (not just Nix).Failure 2: link error —
mold: fatal: library not found: ffiWith the vergen issue worked around, the build now compiles the entire workspace and fails at the final link of the
rethbinary:The final link line contains
-lffiand-lxml2, pulled in via the statically linked LLVM (llvm-sys/revmc-llvm, new in the 2.4.x dependency tree together with thewithLlvm22overlay added toflake.nix). The flake addsllvm.dev/llvm.libto the build, but notlibffiandlibxml2, so in the hermetic Nix build sandbox the linker cannot find them.Workaround that confirms the diagnosis: adding
libffiandlibxml2tobuildInputsof therethderivation makes the build succeed:Suggested fix: add
pkgs.libffiandpkgs.libxml2tobuildInputsin thewithLlvm22override (or wherever the LLVM link deps are declared) inflake.nix.Full workaround used locally
For reference, this
overrideAttrsonpackages.<system>.rethproduces a working v2.4.1 build:Environment
flake.nixat tagv2.4.1v2.3.0builds fine from the same setupHappy to open a PR for either fix if that helps.
Node logs
Platform(s)
Linux (x86)
Container Type
Not running in a container
What version/commit are you on?
v2.4.1 8eb2101
What database version are you on?
database version: 2
Which chain / network are you on?
ethereum mainnet
What type of node are you running?
Full via --full flag
What prune config do you use, if any?
No response
If you've built Reth from source, provide the full command you used
No response
Code of Conduct