diff --git a/flake.nix b/flake.nix index c860a09..7cd30ce 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ kitchenWasmGen = (import ./nix/kitchenWasm/default.nix); moduleGen = (import ./nix/kitchen/module.nix); wasm-packGen = (import ./nix/wasm-pack/default.nix); + wasm-bindgenGen = (import ./nix/wasm-bindgen/default.nix); version = "0.2.24"; in flake-utils.lib.eachDefaultSystem (system: @@ -41,8 +42,9 @@ wasm-pack = wasm-packGen { inherit rust-wasm naersk-lib pkgs; }; + wasm-bindgen = pkgs.callPackage wasm-bindgenGen { inherit pkgs; }; kitchenWasm = kitchenWasmGen { - inherit pkgs rust-wasm version; + inherit pkgs rust-wasm wasm-bindgen version; }; kitchen = (kitchenGen { inherit pkgs version naersk-lib kitchenWasm rust-wasm; @@ -52,7 +54,7 @@ root = ./.; }); kitchenWasmDebug = kitchenWasmGen { - inherit pkgs rust-wasm version; + inherit pkgs rust-wasm wasm-bindgen version; features = "--features debug_logs"; }; kitchenDebug = (kitchenGen { diff --git a/nix/kitchenWasm/default.nix b/nix/kitchenWasm/default.nix index a147789..c6011c7 100644 --- a/nix/kitchenWasm/default.nix +++ b/nix/kitchenWasm/default.nix @@ -2,6 +2,7 @@ version, features ? "", rust-wasm, + wasm-bindgen, }: with pkgs; let @@ -22,8 +23,8 @@ stdenv.mkDerivation { inherit src pname; version = version; # we need wasmb-bindgen v0.2.83 exactly - buildInputs = [ rust-wasm wasm-bindgen-cli wasm-pack binaryen]; - propagatedBuildInputs = [ rust-wasm wasm-bindgen-cli wasm-pack binaryen]; + buildInputs = [ rust-wasm wasm-bindgen wasm-pack binaryen]; + propagatedBuildInputs = [ rust-wasm wasm-bindgen wasm-pack binaryen]; phases = [ "postUnpackPhase" "buildPhase"]; postUnpackPhase = '' ln -s ${cargoDeps} ./cargo-vendor-dir diff --git a/nix/wasm-bindgen/default.nix b/nix/wasm-bindgen/default.nix new file mode 100644 index 0000000..f9f8d19 --- /dev/null +++ b/nix/wasm-bindgen/default.nix @@ -0,0 +1,40 @@ +let + my-lib = import ../lib/lib.nix; +in +{ pkgs +, lib +, rustPlatform +, fetchCrate +, nodejs +, pkg-config +, openssl +, stdenv +, curl +, runCommand +}: + +# This package is special so we don't use the naersk infrastructure to build it. +# Instead we crib from the nixpkgs version with some tweaks to work with our +# flake setup. +rustPlatform.buildRustPackage rec { + pname = "wasm-bindgen-cli"; + # NOTE(jwall): This must exactly match the version of the wasm-bindgen crate + # we are using. + version = "0.2.84"; + + src = fetchCrate { + inherit pname version; + sha256 = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk="; + }; + + cargoSha256 = "sha256-vcpxcRlW1OKoD64owFF6mkxSqmNrvY+y3Ckn5UwEQ50="; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ openssl curl ] ++ (my-lib.darwin-sdk pkgs); + + nativeCheckInputs = [ nodejs ]; + + # other tests require it to be ran in the wasm-bindgen monorepo + cargoTestFlags = [ "--test=interface-types" ]; +} \ No newline at end of file diff --git a/nix/wasm-pack/default.nix b/nix/wasm-pack/default.nix index bfd9a52..5010ab9 100644 --- a/nix/wasm-pack/default.nix +++ b/nix/wasm-pack/default.nix @@ -2,7 +2,6 @@ let my-lib = import ../lib/lib.nix; in {pkgs, - # Because it's a workspace we need the other crates available as source naersk-lib, rust-wasm, }: @@ -11,9 +10,9 @@ with pkgs; pname = "wasm-pack"; version = "v0.11.0"; buildInputs = [ rust-wasm pkgs.openssl curl]; - # However the crate we are building has it's root in specific crate. nativeBuildInputs = (my-lib.darwin-sdk pkgs) ++ [llvm clang pkg-config]; OPENSSL_NO_VENDOR=1; + # The checks use network so disable them here doCheck = false; src = fetchFromGitHub { owner = "rustwasm";