Open umbertov opened 1 year ago
You checkout https://nixos.wiki/wiki/Cross_Compiling - probably something like:
nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.curl
if you want to build curl
I think it's unrelated to bundling
I end up with a
.deb
file foramd64
.
I too experience this issue!
I bundled a cross compiled package from a flake:
$ nix build -L .\?submodules=1\#pythonEnv-armv7l-hf-multiplatform
$ file result/bin/python
result/bin/python: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /nix/store/s9alhnp7zb4pbjlp1ap730drmr3w50lb-glibc-armv7l-unknown-linux-gnueabihf-2.35-224/lib/ld-linux-armhf.so.3, for GNU/Linux 3.10.0, not stripped
I build the bundle with:
$ nix bundle --bundler bundlers#toDEB .\?submodules=1\#pythonEnv-armv7l-hf-multiplatform
And when I try to install the
.deb` file on the target machine, I get:
# dpkg -i *deb
dpkg: error processing archive python3-armv7l-unknown-linux-gnueabihf_1.0_amd64.deb (--install):
package architecture (amd64) does not match system (armhf)
Also the _amd64.deb
suffix indicates this error in detecting the target architecture of the .deb
file.
Yep, the issue is that the .deb
file targets amd64 in its metadata, even if the derivation has arm64 binaries.
I managed to generate a .deb
file for cross compiled binaries without fpm
, which NixOS/bundlers uses via it's nix-utils
flake dependency.
Here's a link to my implementation:
Note that in order to use it you have to know your target architecture's name in Debian's terminology - there is not a ready to use Nix table for that in Nixpkgs' lib.systems
or something like that. I cross compiled my package for armv7l-hf-multiplatform
(Nix terminology) - armhf
(Debian terminology).
Is it possible to bundle e.g. a
.deb
package foraarch64
system when compiling from an x86 system?I'm testing with a very basic cmake c++ hello world, but it seems to me that, even if
nix-build
ornix build -f default.nix
do produceaarch64
binaries (i checked with thefile
command), if i try doingnix bundle -f default.nix --bundler github:NixOS/bundlers#toDEB
, i end up with a.deb
file foramd64
.