-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
90 lines (73 loc) · 2.45 KB
/
flake.nix
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
description = "virtual environments";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.naersk.url = "github:nix-community/naersk";
inputs.fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, flake-utils, devshell, fenix, nixpkgs, naersk, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default fenix.overlays.default ];
};
toolchain = with fenix.packages.${system};
combine [
complete.rustc
complete.cargo
complete.clippy
complete.rust-src
complete.rustc
complete.rustfmt
complete.rust-analyzer
targets.x86_64-pc-windows-gnu.latest.rust-std
pkgs.cargo-flamegraph
];
naersk' = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};
package = mode:
naersk'.buildPackage {
src = ./.;
strictDeps = true;
depsBuildBuild = with pkgs; [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
];
nativeBuildInputs = with pkgs; [
# We need Wine to run tests:
wineWowPackages.stable
];
doCheck = false;
copyBins = false;
copyLibs = true;
release = false;
mode = mode;
TARGET_CC = "x86_64-w64-mingw32-gcc";
TARGET_CXX = "x86_64-w64-mingw32-g++";
# Tells Cargo that we're building for Windows.
# (https://doc.rust-lang.org/cargo/reference/config.html#buildtarget)
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER =
pkgs.writeScript "wine-wrapper" ''
#!/usr/bin/env bash
echo $TARGET_CC
export WINEPREFIX="$(mktemp -d)"
export WINEDLLOVERRIDES=mscoree=d
exec wine64 $@
'';
};
in {
packages.default = package "build";
packages.clippy = package "clippy";
packages.fmt = package "fmt";
});
}