How to build 32-bit application on 64-bit system using Nix package manager

32bitcross-compilationnixnixos

It seems Nix should be able to install and build 32-bit packages on 64-bit systems. It's caches already store whole nixpkgs tree built for i686 architecture, and there should be no problem to download and install them, but I can't see the way to do so.

Best Answer

If you don't already know how to build separate package with nix, here is instruction.

nixpkgs define special variable pkgsi686Linux for i686 packages tree and callPackage_i686 for invoking arbitrary nix-expression with overrided system="i686-linux". Their usage is pretty straightforward.

Method one:

jsoncpp06_32 = nixpkgs.callPackage_i686 ./jsoncpp06.nix { };

method two:

myPackage32 = pkgs.pkgsi686Linux.stdenv.mkDerivation {
    name = "myPackage-i686-0.0.1";

    boost155 = nixpkgs.pkgsi686Linux.boost155;
    buildInputs = [
        pkgs.gcc_multi
        pkgs.python2
        pkgs.pkgconfig

        pkgs.pkgsi686Linux.ffmpeg_2_2
        pkgs.pkgsi686Linux.boost155
        pkgs.pkgsi686Linux.openssl
        pkgs.pkgsi686Linux.curl
        pkgs.pkgsi686Linux.opencv

        jsoncpp06_32
    ];

};
Related Question