nixos-generators icon indicating copy to clipboard operation
nixos-generators copied to clipboard

cross-compile from aarch64-linux to x86_64-linux not working

Open psanford opened this issue 11 months ago • 0 comments

I'm trying to build an x86_64-linux image from my aarch64-linux host, but I get the following error:

$ nix run github:nix-community/nixos-generators --print-build-logs -- --system x86_64-linux -f lxc-metadata
nixos-generate> unpacking sources
nixos-generate> unpacking source archive /nix/store/qmnw7zm5zxcay7n8h24l6hihqj8gx4g5-gdps19axwzli698gn84bnzjx1r9d419a-source
nixos-generate> source root is gdps19axwzli698gn84bnzjx1r9d419a-source
nixos-generate> patching sources
nixos-generate> updateAutotoolsGnuConfigScriptsPhase
nixos-generate> configuring
nixos-generate> no configure script, doing nothing
nixos-generate> building
nixos-generate> build flags: SHELL=/nix/store/apzkylcc8jrmabj07rs5gfzxzbzidpnj-bash-5.2-p15/bin/bash
nixos-generate> make: Nothing to be done for 'all'.
nixos-generate> installing
nixos-generate> install flags: SHELL=/nix/store/apzkylcc8jrmabj07rs5gfzxzbzidpnj-bash-5.2-p15/bin/bash PREFIX=\$\(out\) install
nixos-generate> mkdir -p /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/bin /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/share/nixos-generator
nixos-generate> sed \
nixos-generate>         -e "s|libexec_dir=\".*\"|libexec_dir=\"/nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/share/nixos-generator\"|" \
nixos-generate>         -e "s|#!/usr/bin/env.*|#!/usr/bin/env bash|" \
nixos-generate>         nixos-generate > /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/bin/nixos-generate
nixos-generate> chmod 755 /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/bin/nixos-generate
nixos-generate> cp -r formats format-module.nix configuration.nix lib.nix nixos-generate.nix /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/share/nixos-generator
nixos-generate> post-installation fixup
nixos-generate> shrinking RPATHs of ELF executables and libraries in /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate
nixos-generate> checking for references to /build/ in /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate...
nixos-generate> patching script interpreter paths in /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate
nixos-generate> /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/bin/nixos-generate: interpreter directive changed from "#!/usr/bin/env bash" to "/nix/store/apzkylcc8jrmabj07rs5gfzxzbzidpnj-bash-5.2-p15/bin/bash"
nixos-generate> stripping (with command strip and flags -S -p) in  /nix/store/cikxd3ar5cvs8fm5dpsjpjq3vwdjg77d-nixos-generate/bin
these 2 derivations will be built:
  /nix/store/aq56c2c30p5p5whwzyzqv8n4phw120xs-metadata.yaml.drv
  /nix/store/zfaal2d3xj2pjbddqpz0ljigpj5fsa6p-tarball.drv
building '/nix/store/aq56c2c30p5p5whwzyzqv8n4phw120xs-metadata.yaml.drv'...
error: builder for '/nix/store/aq56c2c30p5p5whwzyzqv8n4phw120xs-metadata.yaml.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/zfaal2d3xj2pjbddqpz0ljigpj5fsa6p-tarball.drv' failed to build

I do have boot.binfmt.emulatedSystems = [ "x86_64-linux" ]; enabled on my host config:

$ cat /proc/sys/fs/binfmt_misc/x86_64-linux
enabled
interpreter /run/binfmt/x86_64-linux
flags: P
offset 0
magic 7f454c4602010100000000000000000002003e00
mask fffffffffffefe00fffffffffffffffffeffffff

I also confirmed that I can execute (at least basic) x86_64 ELFs on this system.

psanford avatar Jul 04 '23 21:07 psanford