Skip to content

Fix applying overrides to defaultCrateOverrides when cross-compiling#266

Draft
lopsided98 wants to merge 1 commit intonix-community:masterfrom
lopsided98:crate-overrides-cross
Draft

Fix applying overrides to defaultCrateOverrides when cross-compiling#266
lopsided98 wants to merge 1 commit intonix-community:masterfrom
lopsided98:crate-overrides-cross

Conversation

@lopsided98
Copy link
Contributor

When cross-compiling, there are different versions of defaultCrateOverrides for each platform. This causes buildRustCrateWithFeatures to think the user has passed a custom value of crateOverrides, which prevents the normal defaultCrateOverrides from being applied. To fix this, use a null default for crateOverrides to detect whether the user has actually specified a value.

This issue can be reproduced by applying a crate override as described here: https://github.com/kolloch/crate2nix#patching-crate-derivations-with-crateoverrides, and then attempting to cross-compile the package. The overrides will not be applied.

When cross-compiling, there are different versions of defaultCrateOverrides for
each platform. This causes buildRustCrateWithFeatures to think the user has
passed a custom value of crateOverrides when cross-compiling, which prevents
defaultCrateOverrides from being applied. To fix this, use a null default for
crateOverrides to detect whether the user has actually specified a value.
@lopsided98
Copy link
Contributor Author

I just realized that this will cause the top-level defaultCrateOverrides argument to be ignored. I need to think about this some more, since I don't understand the exact conditions that trigger the bug.

@lopsided98 lopsided98 marked this pull request as draft December 7, 2022 06:20
@Ericson2314
Copy link
Collaborator

Ericson2314 commented Dec 7, 2022

@lopsided98 yes this has bugged me too --- and I am glad you trying out cross stuff again!

So the thing that has been bugging me is that buildRustCrate really should not take an attribute set of all the overrides, it should accept just the override for just the crate that is being built --- or better yet just accept the arguments to build and have something like overrideAttrs for overriding them.

I think we do that, and the knot will start to untangle and it will become clear what crate2nix ought to do.

But fixing that is easier said that done, sadly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants