I want to build the package stow for the riscv cross compilation target. I use
nix-build --no-out-link -A "pkgsCross.riscv64.stow"
in latest master.
The build fails with configure: error: Perl not found; check your $PATH.
Therefore I’ve added nativeBuildInputs = [ perl ];
to pkgs/tools/misc/stow/default.nix
. After adding that building goes through, but checking the requisities of the package
# nix-store --query --requisites /nix/store/xglqab3yf4pvfj366as6zai8cf81c8zx-stow-2.3.1-riscv64-unknown-linux-gnu
/nix/store/bncqz1jnd3mkssg2rbx3qgqy55bi0m7g-xgcc-13.2.0-libgcc
/nix/store/mgkvalznvc8ik2r9p93445vjbd80ax00-libunistring-1.1
/nix/store/x3wc0s3165pfcakkbbc22j7k5hndc73k-libidn2-2.3.4
/nix/store/7jiqcrg061xi5clniy7z5pvkc4jiaqav-glibc-2.38-27
/nix/store/sbsyp0lvfm44j3k6y2zjpga1fl3xmrdc-attr-2.5.1
/nix/store/4mcxx470kb3lzgnflzpak6ag3vwvndc7-acl-2.3.1
/nix/store/4znq11s8j9d29kj2l4qivl5pyhbbzy8q-zlib-1.3
/nix/store/kbsb6s8djydiawgswnm8j5bwn1yxaqb7-gcc-13.2.0-libgcc
/nix/store/np3cndfk53miqg2cilv7vfdxckga665h-gcc-13.2.0-lib
/nix/store/jp2gz50y8rbkyc0kfnwqznbnlin9ckrh-gmp-with-cxx-6.3.0
/nix/store/5idwbbv23b6vnqdicx97s3hsgrwwnj7j-coreutils-9.4
/nix/store/vqldss7wab1s7mc724887k4amfyql63z-libxcrypt-4.4.36
/nix/store/w33nq3dw39lwjd8zlcdf2zg6jin3a4cb-perl-5.38.2
/nix/store/xglqab3yf4pvfj366as6zai8cf81c8zx-stow-2.3.1-riscv64-unknown-linux-gnu
reveals that the x86 version of perl is used instead of the cross compilation version.
I’ve confirmed that the inputs in nativeBuildInputs
and buildInputs
fit, i.e., are x86 for nativeBuildInputs
and riscv for buildInputs
respectively, by adding the following build command (inspired by nativeBuildInputs gives non native dependencies when used with overrides in all-packages.nix · Issue #49526 · NixOS/nixpkgs · GitHub):
buildCommand = ''
echo PATH=$PATH
echo
echo nbi=$nativeBuildInputs
echo
echo bi=$buildInputs
perl --version
touch $out
'';
Could someone explain what is going on here? For me it’s hard to grasp how the build can have the correct inputs, but still builds a package that has the wrong dependencies. I feel like this is related to nativeBuildInputs gives non native dependencies when used with overrides in all-packages.nix · Issue #49526 · NixOS/nixpkgs · GitHub, but I couldn’t find an answer to this problem there.