[Nix-dev] crosscompiling question

Tomas Hlavaty tom at logand.com
Tue Jul 14 09:03:06 CEST 2015


Hi all,

I am trying to crosscompile nix packages for a bananapi ARM board
following https://nixos.org/wiki/CrossCompiling but I am missing the
last step: how do I actually use the crosscompiled packages?

A working example (bananapi is very similar to beaglebone):

--- /tmp/bananapi/default.nix:
let
  pkgs = import /tmp/nixpkgs/ {
    crossSystem = {
      config = "armv7l-unknown-linux-gnueabihf"; # hf
      bigEndian = false;
      arch = "arm";
      float = "hard";
      fpu = "vfp";
      withTLS = true;
      libc = "glibc";
      platform = pkgs.platforms.beaglebone;
      openssl.system = "linux-generic32";
      gcc = pkgs.platforms.beaglebone.gcc;
    };
  };
in rec {
  hello = pkgs.hello;
  bpiEnv = with pkgs; buildEnv {
    name = "bpiEnv";
    paths = [
      hello.crossDrv
    ];
  };
}
--- end

Running:

$ nix-build -A hello.crossDrv default.nix --option use-binary-caches false

produces
/nix/store/j3l7rg3x9lv167m4as4kfd1mrik9hg0a-hello-2.10-armv7l-unknown-linux-gnueabihf
which I can copy-closure to bananapi and if I call it with absolute path
to that nix-store, it works.

Similarly, I can crosscompile while environment:

$ nix-build -A bpiEnv default.nix --option use-binary-caches false

If I compile hello directly on the bananapi board, I get
/nix/store/rz4n57bas9h9ql5c9if7bpb1wbf1fl89-hello-2.10
which works too.

Like this, I would like to crosscompile packages on my desktop and then
copy-closure them to the board.  However, they are different paths in
the store.  How can I actually achive this?  Is there some trick I am
missing?

Thank you,

Tomas


More information about the nix-dev mailing list