Binaries for cross compilers

Hello,

I’m trying to create a nix-shell with gcc that will cross-compile to arm. It works, but whenever I update nix, or change versions of GCC, I end up having to build it (GCC) from source, which takes quite a while.

Here’s my (simplified) default.nix

with import <nixpkgs> {};
let
  arm = import <nixpkgs> { crossSystem.config = "armv7l-unknown-linux-musleabihf"; };
in
stdenv.mkDerivation {
  name = "foo";
  buildInputs = filter [
    arm.gcc
  ];
}

This seems to be the case regardless of my choice of crossSystem, even if it’s one of the examples from the nixpkgs repo.

Are there pre-built cross compilers somewhere?

Thanks!

If you’re ok with using glibc instead of musl, you could use armv7l-unknown-linux-gnueabihf instead of armv7l-unknown-linux-musleabihf. The official binary cache already has the glibc version of GCC (in nixpkgs unstable it’s /nix/store/74fqm2bidqvf242qawxsl3rl08rarak3-gcc-debug-8.3.0-armv7l-unknown-linux-gnueabihf). You just need to build the gcc wrapper, but this only takes a few seconds.

don’t forget scoping, your stdenv on line 5 is still being inherited from the with import <nixpkgs> {}; on line 1