-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nativeBuildInputs gives non native dependencies when used with overrides in all-packages.nix #49526
Comments
Yes - here you need to use buildPackages. The splicing magic only happens when you use callPackage. |
Indeed wrapping mkDerivation in callPackage solves the problem. But my real problem was when cross compiling talloc, which uses callPackage. It seems giving arguments to callPackage breaks the spliciing: with import <nixpkgs> {
crossSystem = { config = "aarch64-unknown-linux-gnu"; };
};
callPackage ({ stdenv, fetchurl, python, pkgconfig, readline, libxslt
, docbook_xsl, docbook_xml_dtd_42}:
stdenv.mkDerivation {
name = "foo";
nativeBuildInputs = [python];
strictDeps = true;
buildCommand = ''
echo PATH=$PATH
echo nbi=$nativeBuildInputs
python --version
touch $out
'';
}) { python = python2; } This also puts the wrong python2 in the PATH. |
This comment has been minimized.
This comment has been minimized.
My point is:
and then build pkgsCross.whatever.talloc, python will have the wrong architecture. If you remove python = python2 herenixpkgs/pkgs/top-level/all-packages.nix Line 12201 in 06fb025
then splicing is done correctly and python can be run when building talloc. So the minimal working example above is a symptom of a real problem. |
Yeah, I think this is a known problem (although no one has created an issue for it yet, so this will do). It's pretty difficult because all of the splicing happens in Nixpkgs and we have no reference to the "buildPackages" python2 when you do In terms of solutions, there's not really a good solution to me. We could make callPackage support strings so you could do something like:
Then have callPackage replace the string with This is more of a bandaid than anything. There is definitely a need for better solutions. |
What if we used |
/cc @Ericson2314 |
Wow, that's a nice idea! I had written off splicing as unreadably shitty, but I guess there are things to do to make it better until the day we get rid of it entirely. |
Made #58327. The risk is doubly-spliced packages where we |
For now, is it alright to use explicit references to
|
This comment has been minimized.
This comment has been minimized.
The reproducer of the open post still hits the bug. |
Perhaps we could throw or warn when we detect that an input in |
The workaround doesn't work anymore on 21.05: $ cat cross-compile-shell.nix
{ nixpkgs ? fetchTarball "https://github.com/NixOS/nixpkgs/archive/0f8f64b54ed07966b83db2f20c888d5e035012ef.tar.gz"
, pkgs ? (import nixpkgs {}).pkgsCross.aarch64-multiplatform
}:
pkgs.callPackage ({ mkShell, zlib, pkg-config }: mkShell {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ zlib ];
}) {}
$ nix-shell cross-compile-shell.nix --run "pkg-config"
/tmp/nix-shell-492070-0/rc: line 1: pkg-config: command not found |
@domenkozar This is working as intended. |
instead use python3 explicitly in the expression the issue is caused by NixOS#49526
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/cross-compiling-perl-packages-like-stow-riscv-aarch/39221/1 |
Issue description
nativeBuildInputs puts binaries of the wrong architecture on the PATH. That is, binaries cannot be executed on the build architecture.
Note, I am somewhat afraid I could just have misunderstood everything about cross compilation in nixpkgs.
Steps to reproduce
consider this file:
When building it I get
But I expected pkg-config to come from the build architecture (here x86_64-linux), not the cross (native/host) one.
I get the same result if I put pkg-config in
depsBuildBuild
.Technical details
Checked on current nixos-18.03, on 18.09 18.09.932.09195057114 (Jellyfish) and on unstable: 9f88282
The text was updated successfully, but these errors were encountered: