Cross compilation with aarch64 binary cache


I would like to use some custom packages in aarch64 machines, but we use a x86 machine to perform the builds. I have currently managed to compile some the packages needed by cross compiling the dependencies or manually selecting the packages from native builds so we can reuse the nixos cache.

However, I would like to configure the package set so that any packages is fetched from the aarch64 binary cache by default, otherwise, if it’s defined in the overlay it should be cross compiled in the x86 builder machine. Our overlay only affects packages in our own attribute set, so:

self: super:

with self.lib;
  callPackage = callPackageWith (self // foo);
  foo = {
    gcc = callPackage ./gcc {};
    blah = callPackage ./blah {};

Package foo.blah would use our custom foo.gcc, but not bash for example.

I’ve been reading the splice mechanism of callPackage, but I was not able to get it working and I’m not sure I’m understand it properly or if I’m following the proper approach. My idea was to manipulate the pkgsBuildBuild… groups so that by default the aarch64 packages are used, and only add our package set with those packages that need to be cross compiled.

So far I’m only able to either replace all with native packages or all with cross compiled ones.

1 Like