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

Nix cross-compilation #18

Open
samhh opened this issue Oct 30, 2023 · 1 comment
Open

Nix cross-compilation #18

samhh opened this issue Oct 30, 2023 · 1 comment

Comments

@samhh
Copy link
Contributor

samhh commented Oct 30, 2023

nix run works on macOS, however because it's built against our host system the binary fails inside of a container:

$ nix run
2023-10-30T14:53:25.596675Z  WARN No .env found
[...]

$ nix build ".#dockerImage" && ./result | podman load
$ podman run mercury
{"msg":"exec container process `/nix/store/zi27abixfpaq0x4czinw34dyjwvb7lrb-mercury-0.0.0/bin/mercury`: Exec format error","level":"error","time":"2023-10-30T14:55:01.480708Z"}

We could potentially use crossSystem 1, however that loses access to the Nix binary cache, meaning we end up building the universe.

Thus our options for building the container on macOS are:

  • Building the universe.
  • Running an entire Linux container locally, and then running Nix and the container within that (container-ception).
  • Building the binary outside of Nix with cross, and then somehow incorporating that into Nix, or building the image outside of Nix entirely.
  • Using an obscure overlay 2 3 with its own binary cache.

Footnotes

  1. https://n8henrie.com/2023/09/crosscompile-rust-for-x86-linux-from-m1-mac-with-nix/

  2. https://github.com/rustshop/flakebox

  3. https://github.com/alekseysidorov/nixpkgs-cross-overlay

@samhh
Copy link
Contributor Author

samhh commented Oct 31, 2023

This may also affect the container itself as per podman image inspect's Architecture.

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

No branches or pull requests

1 participant