Skip to content

Standardize Cross-Compilation and Enable Pure Flakes#505

Open
petm5 wants to merge 7 commits into
nix-community:masterfrom
petm5:better-cross-compile-1
Open

Standardize Cross-Compilation and Enable Pure Flakes#505
petm5 wants to merge 7 commits into
nix-community:masterfrom
petm5:better-cross-compile-1

Conversation

@petm5
Copy link
Copy Markdown

@petm5 petm5 commented Feb 22, 2026

These changes refactor the build pipeline for talloc, proot-static, and the bootstrap zipball to use standard nixpkgs cross-compilation infra. By doing so, we remove the need for custom cross-compilation logic and allow system configurations without the --impure flag.

Highlights:

  • Nixpkgs is updated to take advantage of general cross-compilation improvements.
  • proot is updated to prevent SIGBUS crashes on aarch64 when built against musl and recent LLVM (termux/proot@28baec5).
  • The hard-coded proot and talloc store paths in nixOnDroidConfiguration are replaced with a nixpkgs-native LLVM/musl cross toolchain. The same toolchain is used to build the bootstrap zipball.
  • Modified the talloc package so it can be built outside of a cross-compilation environment.
  • Removed the custom cross-compiler infrastructure and cross-compiled package specifications as they are no longer necessary.
  • Nix store initialization is now handled on-device during initial setup in login-inner. This lets us avoid duplicating the logic of nix-store --init.
  • The hard-coded nix release tarball is replaced with a native package from nixpkgs.

It is possible to specify what architecture will be used to cross-compile the static components. The idea is they could be built on an x86_64-linux system and stored in a binary cache so aarch64 devices can use them even if they can't be built natively.

The changes were tested and validated on my own device (Samsung Galaxy A15) using a custom binary cache and bootstrap server. I could switch to a home-manager enabled profile without it throwing bus errors.

Further changes may be needed to maintain compatibility with the release scripts and GitHub Actions checks.

talloc and proot are now built using LLVM and musl, using a native cross
compiler toolchain from nixpkgs. The cross package environment is passed
through the module system via crossPkgs. This allows flakes to be built
without --impure.
Following the previous commit, we can now use crossPkgs and take
advantage of nixpkgs' cross-compilation features to build the bootstrap
zipball. This makes the custom cross-compiler infrastructure
unnecessary, so remove it.

The platform's native package set is now passed through the module
system via targetPkgs. This lets us replace the Nix tarball download
with a native package. Since store initialization does not happen at
build time anymore, is now performed on the device during login-inner.
@t184256
Copy link
Copy Markdown
Collaborator

t184256 commented Mar 1, 2026

That's very interesting, should be landed after a release once I finally force myself to make one.

Note to self: I also wonder whether it's posible to hop off musl/LLVM altogether with that SIGBUS fix. IIRC, the symptom that made us abandon glibc/GCC 7 years ago was also manifesting itself as an inexplicable SIGBUS: #6 (comment)

@petm5
Copy link
Copy Markdown
Author

petm5 commented Mar 1, 2026

I also wonder whether it's posible to hop off musl/LLVM altogether

AFAIK the whole point of using musl is to enable static linking since glibc doesn't support it well. How would a dynamically-linked proot work without hacks like a custom Nix store path?

@t184256
Copy link
Copy Markdown
Collaborator

t184256 commented Mar 2, 2026 via email

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