2022-02-25 19:10:55 -05:00
|
|
|
{pkgs? (import <nixpkgs>) {},
|
|
|
|
version ? "0.2.1",
|
|
|
|
cargoVendorDeps ? (import ./../cargoVendorDeps/default.nix {inherit pkgs version; }),
|
2022-03-06 15:16:30 -05:00
|
|
|
rust-wasm,
|
2022-02-25 19:10:55 -05:00
|
|
|
trunk ? (import ./../trunk/default.nix {inherit pkgs;}),
|
|
|
|
}:
|
|
|
|
with pkgs;
|
|
|
|
let
|
|
|
|
pname = "kitchen-wasm";
|
2022-02-28 14:28:21 -05:00
|
|
|
src = ./../..;
|
2022-02-25 19:10:55 -05:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit src pname;
|
|
|
|
version = version;
|
2022-06-14 18:25:05 -04:00
|
|
|
# we need wasmb-bindgen v0.2.78 exactly
|
|
|
|
buildInputs = [ rust-wasm wasm-bindgen-cli wasm-pack binaryen];
|
2022-03-06 15:16:30 -05:00
|
|
|
phases = [ "postUnpackPhase" "buildPhase"];
|
2022-02-25 19:10:55 -05:00
|
|
|
postUnpackPhase = ''
|
|
|
|
ln -s ${cargoVendorDeps} ./cargo-vendor-dir
|
|
|
|
cp -r ./cargo-vendor-dir/.cargo ./
|
|
|
|
cp -r $src/* ./
|
|
|
|
'';
|
2022-02-28 14:28:21 -05:00
|
|
|
# TODO(jwall): Build this from the root rather than the src.
|
2022-02-25 19:10:55 -05:00
|
|
|
buildPhase = ''
|
2022-06-14 18:25:05 -04:00
|
|
|
echo building with wasm-pack
|
2022-02-25 19:10:55 -05:00
|
|
|
mkdir -p $out
|
2022-03-06 15:16:30 -05:00
|
|
|
cd web
|
2022-06-14 18:25:05 -04:00
|
|
|
cp -r static $out
|
|
|
|
wasm-pack build --target web --out-dir $out;
|
|
|
|
cp -r index.html $out
|
2022-02-25 19:10:55 -05:00
|
|
|
'';
|
|
|
|
}
|