Bring in wasm-pack directly to preserve keep control over it even more

This commit is contained in:
Jeremy Wall 2023-03-21 17:24:11 -04:00
parent fafcf6f981
commit 5df86e33ac
3 changed files with 38 additions and 3 deletions

View File

@ -17,6 +17,7 @@
kitchenGen = (import ./nix/kitchen/default.nix);
kitchenWasmGen = (import ./nix/kitchenWasm/default.nix);
moduleGen = (import ./nix/kitchen/module.nix);
wasm-packGen = (import ./nix/wasm-pack/default.nix);
version = "0.2.24";
in
flake-utils.lib.eachDefaultSystem (system:
@ -34,6 +35,11 @@
rustc = rust-wasm;
cargo = rust-wasm;
};
# We've run into a few problems with the bundled wasm-pack in nixpkgs.
# Better to just control this part of our toolchain directly.
wasm-pack = wasm-packGen {
inherit rust-wasm naersk-lib pkgs;
};
kitchenWasm = kitchenWasmGen {
inherit pkgs rust-wasm version;
};
@ -72,6 +78,10 @@
type = "app";
program = "${kitchen}/bin/kitchen";
};
devShell = pkgs.callPackage ./nix/devShell/default.nix {
inherit rust-wasm;
wasm-pack-hermetic = wasm-pack;
};
}
);
}
}

View File

@ -1,8 +1,8 @@
let
lib = import ../lib/lib.nix;
in
{ pkgs, rust-wasm, wasm-pack }:
{ pkgs, rust-wasm, wasm-pack-hermetic }:
with pkgs;
mkShell {
buildInputs = (lib.darwin-sdk pkgs) ++ (with pkgs; [wasm-bindgen-cli wasm-pack llvm clang rust-wasm]);
buildInputs = (lib.darwin-sdk pkgs) ++ (with pkgs; [wasm-bindgen-cli wasm-pack-hermetic llvm clang rust-wasm]);
}

25
nix/wasm-pack/default.nix Normal file
View File

@ -0,0 +1,25 @@
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,
}:
with pkgs;
(naersk-lib.buildPackage rec {
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;
doCheck = false;
src = fetchFromGitHub {
owner = "rustwasm";
repo = "wasm-pack";
rev = version;
sha256 = "sha256-3iwXoYnmrZsbwFUR41uI/4jnCF0OjeRO7UqVDaGJJbQ=";
};
cargoBuildOptions = opts: opts ++ ["-p" "${pname}" ];
})