Nix on armv7l fails to build any packge

I have an Orange Pi One, which is an armv7l board.

I have reproduced this same issue with Nix (just nix, not NixOS) on two Linux distributions: Armbian and Ubuntu.

The first thing that I did was to install Nix. In both cases I had a fresh install of the distribution.

If you check this installation script there is a case for armv7l:
armv7l_linux case at line 48, which values is from uname -m. The first try failed because it couldn’t find a valid platform for my board (weird, right? because my board is armv7l).
So I checked the command uname -m and the result is armv7land not armv7l_linux. Okey, I can workaround this, it’s just a small patch.

Installation follows normally after this small patch.

However, when I try to install any package I get an error for the package gnum4 (it’s always this failure, no matter which package I’m installing).

For example, if I try nix-shell -p python, it starts to download the dependencies, but it fails with the error message:

(omitting some lines here)...
copying path '/nix/store/d45swm00n7hzd4lbsrgr7mbvpggp447c-readline63-002' from 'https://cache.nixos.org'...
copying path '/nix/store/g21ljc0vdfwd1ghbskl02gbvl3fix91q-readline63-003' from 'https://cache.nixos.org'...
copying path '/nix/store/rg0qgkpq25cvdl351k7k935npsrgp72d-readline63-004' from 'https://cache.nixos.org'...
copying path '/nix/store/yw6qjz5zvvl28jvlqmppsf2qkadwipq5-readline63-005' from 'https://cache.nixos.org'...
copying path '/nix/store/q2paclh2vvbnz8sz6rjxzq1gbxkz91gb-readline63-006' from 'https://cache.nixos.org'...
copying path '/nix/store/11s8h9krz4xbzxm8qrbszmk5snjlvfa6-readline63-007' from 'https://cache.nixos.org'...
copying path '/nix/store/qhylrz27y60rcivasp7frghy9j8ia2f4-readline63-008' from 'https://cache.nixos.org'...
copying path '/nix/store/a9nrp90fd81k99a327ff6j5qivp3mwwy-sqlite-autoconf-3360000.tar.gz' from 'https://cache.nixos.org'...
building '/nix/store/6lgdrylcxifjaqgz7gizcm37xkw9481x-gnum4-1.4.19.drv'...
unpacking sources
unpacking source archive /nix/store/mcayf992diwks293vs12iwx1ywgm4ijg-m4-1.4.19.tar.bz2
source root is m4-1.4.19
setting SOURCE_DATE_EPOCH to timestamp 1622228112 of file m4-1.4.19/ChangeLog
patching sources
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/w9b8jfa48ri0041dkr2jjpvdmp1qmjyy-gnum4-1.4.19 --with-syscmd-shell=/nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools/bin/bash
/nix/store/yx05p52ik9j1ws4x035pyfi4w8ns9zy8-bootstrap-stage1-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory
error: builder for '/nix/store/6lgdrylcxifjaqgz7gizcm37xkw9481x-gnum4-1.4.19.drv' failed with exit code 126
error: 1 dependencies of derivation '/nix/store/igs9xq6vz3razhf9va56lxjdgpqm3gzq-autoconf-2.71.drv' failed to build
error: 1 dependencies of derivation '/nix/store/zzml6wkphgbs9132qxmc4l3zc17yymf7-autoconf-2.71.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rwxff1a8yw5axwwf1n0pgzk6c8mzi6pq-bison-3.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/h90d6pwbhqqaiz8s9knj1amqwiwayyz1-gmp-6.2.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wdlap6n7s0zii1n2v5g08ia0mfzcm63n-bash-5.1-p12.drv' failed to build
error: build of '/nix/store/dpii3z29hcz3pv5jk3maiby2kfwlnia9-python-2.7.18.drv', '/nix/store/h7a0inn85zhz086hkl6nyxxb4gyg6yk7-bash-interactive-5.1-p12.drv', '/nix/store/ij7dgaq4jkbaw6m5r8z937i1cr7m74bq-stdenv-linux.drv', '/nix/store/wdlap6n7s0zii1n2v5g08ia0mfzcm63n-bash-5.1-p12.drv' failed

Please let me know if I should open an issue in the repo.

Have you by any chance found a solution or workaround the problem ? I am still facing it on a Raspberry Pi 2B.

No progress here from my side.

That’s quite annoying… you should report it on github (also, note that you won’t have binary cache, unless you find some community maintained ones, as armv7 is not built by hydra).

The weird thing is the /bin/sh: bad interpreter: No such file or directory, that seems to suggest that for some reasons gnum4’s build script is not patched correctly an armv7… I would say that the problematic line is in this archive, then the #! /bin/sh is used in the first line of the ./configure file that seems to be problematic. My guess is that somehow during the bootstrap phase, this is not patched (to be honest I’m not even sure to know how patching is supposed to be done during this bootstrap phase, and why it succeeds on x86_64, maybe a quick look at https://github.com/NixOS/nixpkgs/tree/master/pkgs/stdenv/linux would help). As a quick workaround I would try to add an overlay to add a preConfigure phase containing explicit patching, like

self: super: {
  gnum4 = super.gnum4.overrideAttrs (old: {
  preConfigure = ''
    patchShebangs ./configure
  '';    
  });
};

For now I’m trying to reproduce using:

# enable boot.binfmt.emulatedSystems = [ "armv7l-linux" ];
$ nix build 'nixpkgs#legacyPackages.armv7l-linux.gnum4'

but for now I get no errors… just it takes forever because of the emulation layer. Is it working for you using flake? Or maybe you get an error even earlier when bootstraping…

So… that’s the weird thing, this PR is basically doing the same thing and it still does not build on the host platform.

I did here !