I am trying to build relibc using nix and rust nightly with the rust-src extension. It uses git submodules who have the dependency cfg-if = "1.0", but this leads to an error of resolving the correct version. cargo insits on using 1.0.3 while std insits on using 1.0.1.
Using this expression where src is the git repo with submodules:
{
lib,
stdenv,
buildPackages,
rust,
src,
rust-cbindgen,
expect,
}:
let
redoxRustPlatform = buildPackages.makeRustPlatform {
rustc = rust;
cargo = rust;
};
target = stdenv.hostPlatform.rust.rustcTargetSpec;
lockFile = ./Cargo.lock;
in
redoxRustPlatform.buildRustPackage {
pname = "relibc";
version = "latest";
LD_LIBRARY_PATH = "${buildPackages.zlib}/lib";
src = src;
RUSTC_BOOTSTRAP = 1;
dontInstall = true;
dontFixup = true;
doCheck = false;
buildPhase = ''
make CC=gcc AR=ar LD=ld NM=nm all
'';
postBuild = ''
mkdir -p $out
DESTDIR=$out make CC=gcc AR=ar LD=ld NM=nm install
'';
nativeBuildInputs = [
rust-cbindgen
expect
];
TARGET = target;
cargoLock = {
lockFile = lockFile;
allowBuiltinFetchGit = true;
outputHashes = {
"cc-1.1.22" = "sha256-qHnTYnx6aUDDZSuoVX521HPc6oC5mF4qJDCJEDZe9u0=";
"object-0.36.7" = "sha256-vKH7JPy84mt5W2vyH3nK2u64TroKSw+OiXXg2bTAHGU=";
"redox_event-0.4.0" = "sha256-6DPFABc5bG6bppDzmLQ3q0gHQcmnooIY27H661h+Ees==";
"redox_syscall-0.5.18" = "sha256-cpQ+/3qR4+/1rKqrwb3ok25leiohBvOWLnTk3k5sWTg=";
};
};
# error: Usage of `RUSTC_WORKSPACE_WRAPPER` requires `-Z unstable-options`
auditable = false;
meta = with lib; {
homepage = "https://gitlab.redox-os.org/redox-os/relibc";
description = "C Library in Rust for Redox and Linux";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.redox ++ [ "x86_64-linux" ];
};
}
relibc-latest> error: failed to select a version for the requirement `cfg-if = "^1.0"` (locked to 1.0.1)
relibc-latest> candidate versions found which didn't match: 1.0.3
relibc-latest> location searched: directory source `/build/cargo-vendor-dir` (which is replacing registry `crates-io`)
relibc-latest> required by package `std v0.0.0 (/nix/store/xfljfal6ycn3q5m93v8ycc3qvwn46i8j-rust-nightly-2025-10-03/lib/rustlib/src/rust/library/std)`
relibc-latest> ... which satisfies path dependency `std` (locked to 0.0.0) of package `sysroot v0.0.0 (/nix/store/xfljfal6ycn3q5m93v8ycc3qvwn46i8j-rust-nightly-2025-10-03/lib/rustlib/src/rust/library/sysroot)`
relibc-latest> perhaps a crate was updated and forgotten to be re-vendored?
relibc-latest> make: *** [Makefile:238: /build/source/target/x86_64-unknown-linux-gnu/release/librelibc.a] Error 101
Source code:
However this is not a problem when running the build directly from the terminal using nix develop and make CC=gcc AR=ar LD=ld NM=nm all.
So what is happening here?