Fix cargo dependencies issue with nix wasm-pack

This commit is contained in:
Jeremy Wall 2022-08-25 20:35:26 -04:00
parent 6ea7762f37
commit ba64e5a094

View File

@ -8,6 +8,10 @@ with pkgs;
let let
pname = "kitchen-wasm"; pname = "kitchen-wasm";
src = ./../..; src = ./../..;
lockFile = ./../../Cargo.lock;
# NOTE(jwall): Because we use wasm-pack directly below we need
# the cargo dependencies to already be installed.
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile; });
in in
stdenv.mkDerivation { stdenv.mkDerivation {
inherit src pname; inherit src pname;
@ -17,7 +21,7 @@ stdenv.mkDerivation {
propagatedBuildInputs = [ rust-wasm wasm-bindgen-cli wasm-pack binaryen]; propagatedBuildInputs = [ rust-wasm wasm-bindgen-cli wasm-pack binaryen];
phases = [ "postUnpackPhase" "buildPhase"]; phases = [ "postUnpackPhase" "buildPhase"];
postUnpackPhase = '' postUnpackPhase = ''
ln -s ${cargoVendorDeps} ./cargo-vendor-dir ln -s ${cargoDeps} ./cargo-vendor-dir
cp -r ./cargo-vendor-dir/.cargo ./ cp -r ./cargo-vendor-dir/.cargo ./
cp -r $src/* ./ cp -r $src/* ./
''; '';