This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
76 lines (67 loc) · 2.26 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
{
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "nixpkgs/nixos-unstable";
};
# Copy of example config from https://github.com/nix-community/naersk/tree/master/examples/multi-target
outputs = { self, fenix, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
};
toolchain = with fenix.packages.${system};
combine [
complete.cargo
complete.rustc
complete.rust-src
targets.x86_64-unknown-linux-musl.latest.rust-std
targets.wasm32-unknown-unknown.latest.rust-std
];
naersk' = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};
naerskBuildPackage = target: args:
naersk'.buildPackage (
args
// { CARGO_BUILD_TARGET = target; }
// cargoConfig
);
cargoConfig = {
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS = "-C target-feature=+crt-static";
};
in rec {
defaultPackage = packages.wasm32-unknown-unknown;
# For `nix build .#x86_64-unknown-linux-musl`:
packages.x86_64-unknown-linux-musl = naerskBuildPackage "x86_64-unknown-linux-musl" {
src = ./.;
doCheck = true;
nativeBuildInputs = with pkgs; [ pkgsStatic.stdenv.cc ];
};
packages.wasm32-unknown-unknown = naerskBuildPackage "wasm32-unknown-unknown" {
src = ./.;
## Unable to run tests on wasm32: do not do check
copyBins = false;
copyLibs = true;
};
devShell = pkgs.mkShell (
{
inputsFrom = with packages; [ x86_64-unknown-linux-musl ];
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
shellHook = ''
export PATH=$PATH:~/.cargo/bin
'';
} // cargoConfig
);
}
);
}