Sorry, I haven’t updated this in a while.
My equivalent nix-shell (using Niv, and the Mozilla overlay) is:
let
sources = import ./nix/sources.nix;
rust = import ./nix/rust.nix{inherit sources;};
pkgs = (import <nixpkgs>{ crossSystem = {config = "x86_64-w64-mingw32";}; });
in
pkgs.mkShell {
nativeBuildInputs = [ rust ];
}
And a rust.nix:
{sources ? import ./sources.nix}:
let
pkgs = import sources.nixpkgs{ overlays = [ (import sources.nixpkgs-mozilla) ]; };
channel = "nightly";
date = "2020-10-14";
targets = [ "x86_64-pc-windows-gnu" ];
chan = (pkgs.rustChannelOfTargets channel date targets);
in chan
My .cargo/config is identical to yours, and after entering the shell I cans see that the corresponding compiler does exist in the path:
✦ ❯ which x86_64-w64-mingw32-gcc /nix/store/ir564pg2s96nmrc3xlvfh065wk9hblj6-x86_64-w64-mingw32-stage-final-gcc-debug-wrapper-8.3.0/bin/x86_64-w64-mingw32-gcc
This gets me a shell with a mingw compiler and a rust toolchain. I can build native Linux executables fine. However, when I try to cross-compile for x86_64-pc-windows-gnu I get a linker error related to pthreads:
= note: /nix/store/n8rscm777z53g1cg6knwwphik3aprx6j-x86_64-w64-mingw32-binutils-2.31.1/bin/x86_64-w64-mingw32-ld: cannot find -l:libpthread.a collect2: error: ld returned 1 exit status
error: aborting due to previous error; 2 warnings emitted
This pthreads issue is where I’ve been stuck for the past couple days. It’s also not clear to me why cargo seems to still be linking with ld instead of gcc despite .cargo/config. Any ideas?