-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwasm.nix
64 lines (56 loc) · 1.47 KB
/
wasm.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
{
rustPlatform,
nodejs_20,
pkg-config,
openssl,
fetchCrate,
rust-bin,
wasm-pack,
binaryen,
lib
}: let
deps = (builtins.fromTOML (builtins.readFile ./wasm/Cargo.toml)).dependencies;
wasm-bindgen-version = lib.strings.removePrefix "=" deps.wasm-bindgen.version;
wasm-bindgen-cli = rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = wasm-bindgen-version;
src = fetchCrate {
inherit pname version;
sha256 = "sha256-X8+DVX7dmKh7BgXqP7Fp0smhup5OO8eWEhn26ODYbkQ=";
};
cargoHash = "sha256-ckJxAR20GuVGstzXzIj1M0WBFj5eJjrO2/DRMUK5dwM=";
nativeBuildInputs = [pkg-config];
buildInputs = [openssl];
checkInputs = [nodejs_20];
dontCargoCheck = true;
};
rust-wasm = rust-bin.stable.latest.default.override {
targets = ["wasm32-unknown-unknown"];
};
in
rustPlatform.buildRustPackage rec {
name = "demo-inspector-wasm";
version = "0.1.0";
cargoLock = {
lockFile = ./wasm/Cargo.lock;
outputHashes = {
"tf-demo-parser-0.5.0" = "sha256-bwQ4AqF+YMXBVLi7mxGSqZhj6+P086pNT1QR5ivTB8U=";
};
};
src = ./wasm;
WASM_PACK_CACHE = "/build/cache";
nativeBuildInputs = [rust-wasm wasm-pack wasm-bindgen-cli binaryen];
buildPhase = ''
runHook preBuild
(
set -x
wasm-pack build --mode no-install
)
runHook postBuild
'';
dontCargoBuild = true;
dontCargoCheck = true;
installPhase = ''
cp -r pkg $out
'';
}