Skip to content
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

true cross-compilation? #160

Open
SilentVoid13 opened this issue Jun 26, 2024 · 4 comments · May be fixed by #161
Open

true cross-compilation? #160

SilentVoid13 opened this issue Jun 26, 2024 · 4 comments · May be fixed by #161

Comments

@SilentVoid13
Copy link
Contributor

SilentVoid13 commented Jun 26, 2024

Hey there, I have a question about cross-compilation with flakebox. It seems to work perfectly as long as you don't have any external pkgs dependencies.

If you do, you want to be using pkgsCross.<target> instead of pkgs for the buildInputs and nativeBuildInputs, but there are no easy way to specify that with flakebox's craneMultiBuild.

A hacky way to manually make it work for a target is to specify the target's pkgs in your flake with:

    pkgs = import nixpkgs {
      localSystem = "x86_64-linux";
      crossSystem.config = "aarch64-unknown-linux-gnu";
    };

To make the cross-compilation work, but of course this is now imposing the aarch64 pkgs on all targets, which is not the point.

Am I missing something or is that a limitation of flakebox?
I did take a look at flakebox's source to make it work, but it doesn't seem like a trivial change. My idea would be to accept a pkgsCross function for craneMultiBuild that would look like this:

          nativeBuildInputs = pkgsCross: [
            pkgsCross.openssl
            pkgsCross.sqlite
          ];

This would somehow be forwarded to mkStdTargets where the correct pkgs would be resolved and later passed to mkTarget.

Thoughts about it?

@dpc
Copy link
Contributor

dpc commented Jun 26, 2024

@SilentVoid13 I think your approach might be better, but here's how we've dealt with linking with compiled libraries when cross-compiling:

https://github.com/fedimint/fedimint/blob/748bcfaff28f2d5e396f169065ba60c2053472a4/nix/flakebox.nix#L82

@dpc
Copy link
Contributor

dpc commented Jun 26, 2024

Generally cross-compiling is a PITA, Flake do not have a native support for it, stuff often hits some corner cases etc.

Crane is still doing some fixes too:
ipetkov/crane#652

@dpc
Copy link
Contributor

dpc commented Jun 26, 2024

We could relatively easily add support in mergeArgs to support elements of the list which are lambdas pkgsCross: ... and evaluate over specific pkgCross in craneMultiBuild. It wouldn't be a huge change, I guess.

If you have some time, please submit a PR. @SilentVoid13 .

@SilentVoid13
Copy link
Contributor Author

Thanks for the reply, I'll take a look at it and see if I come up with something functional.

@SilentVoid13 SilentVoid13 linked a pull request Jun 30, 2024 that will close this issue
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 a pull request may close this issue.

2 participants