-
Notifications
You must be signed in to change notification settings - Fork 86
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
Crane is no longer able to cross-compile with an overridden toolchain #648
Comments
I think |
I managed to work around this issue like so: mkToolchain = p:
let
toolchain = p.rust-bin.stable.latest.default;
in
{
cargo = toolchain;
clippy = toolchain;
rustc = toolchain;
rustfmt = toolchain;
};
otherSplices = {
selfBuildBuild = mkToolchain pkgs.pkgsBuildBuild;
selfBuildHost = mkToolchain pkgs.pkgsBuildHost;
selfBuildTarget = mkToolchain pkgs.pkgsBuildTarget;
selfHostHost = mkToolchain pkgs.pkgsHostHost;
selfHostTarget = mkToolchain pkgs.pkgsHostTarget;
selfTargetTarget = { }; # usually empty
};
craneLib = import "${crane}/lib" {
inherit (pkgs) lib makeScopeWithSplicing';
inherit otherSplices;
}; I'm not sure what the best way to expose this as an API. A few ideas:
Or both? 1 is a bit low level, and 2 assumes that you overlay the toolchain over nixpkgs (which you might not want to). |
Hi @szlend thanks for the report! I still don't fully grok how Anyways I'll try to take a look at this sometime next week, but if anyone figures things out feel free to submit a PR! |
Here's a quick explanation of
pkgset = makeScopeWithSplicing' {
f = self: {
foo = self.callPackage ./foo.nix {};
# ...
};
};
# only the attributes you defined in `f` are accessible
foo = pkgset.foo.outPath; # OK
jq = pkgset.jq.outPath; # Missing attribute
# however in `pkgset.callPackage` you now have `pkgs // pkgset`:
fooAndJqPath = pkgset.callPackage ({ foo, jq }: "${foo.outPath} and ${jq.outPath}") {}; So far this is similar to pkgset = makeScopeWithSplicing' {
otherSplices = {
# We define all the different variations of our package set here
# `mkPackagesFor` is a placeholder for a function that builds your package set with a different `pkgs` scope
# This could just be a recursive call into another `makeScopeWithSplicing'` with `pkgs.pkgsBuildHost` instead of `pkgs`
selfBuildHost = mkPackagesFor pkgs.pkgsBuildHost;
# ...
};
};
# We can see our package now has a `__spliced` attribute when captured from `callPackage`.
# When you put `foo` into `buildInputs` / `nativeBuildInputs` / etc, the correct variant
# from `__spliced` is picked for you. This attribute only exists when `crossSystem` is set
splicedForBuildHost = pkgset.callPackage ({ foo }: foo.__spliced.buildHost) {}; Usually in If you use rust-overlay (overlayed on top of nixpkgs), you could technically do something like this: makeScopeWithSplicing' {
f = _self: pkgs.rust-bin.stable.latest;
otherSplices = generateSplicesForMkScope "rust-bin.stable.latest"
} This is basically the equivalent of |
Happy to contribute something myself as well, but we'd need to discuss how the API for this should look like. Imo we could support this in two ways:
One caveat is that we can't use |
This also means that I hacked a quick PoC in #650, but I'm not sure what we should do about |
An alternative (backwards compatible) attempt is in #652. |
Describe the bug
After #634 crane is no longer able to cross-compile with an overridden toolchain. Instead it will always use
cargo
/rustc
fromnixpkgs
.Reproduction
nix-tree --derivation .#default
rustc-1.73.0
is in the build closure (expectedrustc-1.79.0
)Removing
crossSystem
fixes the issue andrustc-1.79.0
is used again.The text was updated successfully, but these errors were encountered: