Skip to content

Instantly share code, notes, and snippets.

@vcunat
Created December 4, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vcunat/88564cd00406a954aa671a2de93228a4 to your computer and use it in GitHub Desktop.
Save vcunat/88564cd00406a954aa671a2de93228a4 to your computer and use it in GitHub Desktop.
Linux->mingw cross-compiling shim: *-native is for packages not meant to be run on windows
let
lib = (import <nixpkgs> {}).lib;
pkgs-cross-xx = hostArch:
lib.mapAttrs
(name_: pkg: if lib.isDerivation pkg then pkg.crossDrv else pkg)
(pkgs-cross-xx-nocross hostArch);
pkgs-cross-xx-nocross = hostArch:
(import <nixpkgs> {
crossSystem = {
config = hostArch + "-w64-mingw32";
arch = if hostArch == "i686" then "x86" else hostArch; # Irrelevant
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
platform = {};
openssl.system = "mingw"
+ lib.optionalString (hostArch == "x86_64") "64";
};
});
in {
w32 = pkgs-cross-xx "i686";
w64 = pkgs-cross-xx "x86_64";
w32-native = pkgs-cross-xx-nocross "i686";
w64-native = pkgs-cross-xx-nocross "x86_64";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment