blob: 7ed52965a60d86c6fd2d8e92108ce310bdd1c819 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{ mkShell, pkgsCross, fenix }:
# Reference: https://github.com/nix-community/naersk/blob/aeb58d5e8faead8980a807c840232697982d47b9/examples/cross-windows/flake.nix
let
channel = "stable";
targets = with fenix.targets; [
x86_64-unknown-linux-gnu
i686-unknown-linux-gnu
aarch64-unknown-linux-gnu
aarch64-apple-darwin
x86_64-apple-darwin
];
crossCompileTargets = with fenix.targets; [
x86_64-pc-windows-gnu
];
toolchain = fenix.combine (with fenix.${channel}; [
cargo
rustc
] ++ map (target: target.${channel}.toolchain) targets
++ map (target: target.${channel}.rust-std) crossCompileTargets);
in
mkShell {
buildInputs = with pkgsCross.mingwW64; [
stdenv.cc
];
packages = [ toolchain ];
# Link to libpthreads manually otherwise build fails
# See: https://github.com/NixOS/nixpkgs/issues/139966#issuecomment-1385222547
env.CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS = "-L native=${pkgsCross.mingwW64.windows.pthreads}/lib";
}
|