-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
43 lines (36 loc) · 1.27 KB
/
default.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
{ pkgs, nixpkgs, system, crane, rust-overlay }:
let
rustPkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustVersion = "1.74.0";
wasmTarget = "wasm32-unknown-unknown";
rustWithWasmTarget = rustPkgs.rust-bin.stable.${rustVersion}.default.override {
targets = [ wasmTarget ];
};
craneLib = crane.mkLib pkgs;
# NB: we don't need to overlay our custom toolchain for the *entire*
# pkgs (which would require rebuidling anything else which uses rust).
# Instead, we just want to update the scope that crane will use by appending
# our specific toolchain there.
craneLibWasm = craneLib.overrideToolchain rustWithWasmTarget;
in
{
cli = craneLib.buildPackage {
src = ./.;
cargoExtraArgs = "-p cli";
nativeBuildInputs = [ pkgs.pkg-config ];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};
wasm = craneLibWasm.buildPackage {
src = ./.;
cargoExtraArgs = "-p wasm --target ${wasmTarget}";
# Override crane's use of --workspace, which tries to build everything.
cargoCheckCommand = "cargo check --release";
cargoBuildCommand = "cargo build --release";
# Tests currently need to be run via `cargo wasi` which
# isn't packaged in nixpkgs yet...
doCheck = false;
};
}