Skip to content

Commit

Permalink
Making wasm-bindgen work
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Aug 13, 2024
1 parent 9bbfac6 commit 15df976
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions codecs/resize/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,37 @@
rustc = toolchain;
cargo = toolchain;
};
src = ./.;
cargoLock = pkgs.lib.importTOML "${src}/Cargo.lock";
wasm-bindgen-version =
(pkgs.lib.lists.findFirst (x: x.name == "wasm-bindgen") null cargoLock.package).version;
in
with pkgs;
{
packages = rec {
default = resize-squoosh;
resize-squoosh = stdenv.mkDerivation {
name = "squoosh-resize";
src = ./.;
inherit src;
nativeBuildInputs = [
#naersk'
toolchain
curl
iconv
# wasm-pack
wasm-bindgen-cli
# wasm-bindgen-cli
];
dontConfigure = true;
postUnpack = ''
export CARGO_HOME=$TMPDIR/.cargo
cargo install -f wasm-bindgen-cli --version ${wasm-bindgen-version}
'';
buildPhase = ''
runHook preBuild
export CARGO_HOME=$TMPDIR/.cargo
cargo build --target wasm32-unknown-unknown -r
wasm-bindgen --target web --out-dir $out ./target/wasm32-unknown-unknown/release/*.wasm
$CARGO_HOME/bin/wasm-bindgen --target web --out-dir $out ./target/wasm32-unknown-unknown/release/*.wasm
runHook postBuild
'';
dontInstall = true;
# installPhase = ''
Expand Down

0 comments on commit 15df976

Please sign in to comment.