Files
wordle-solver-rs/nix/wordle-solver-wasm.nix
2026-08-19 20:59:30 +02:00

40 lines
735 B
Nix

{
rustPlatform,
buildPackages,
lld,
name ? "wordle-solver",
...
}:
rustPlatform.buildRustPackage {
inherit name;
src = ../.; # Or your source location
cargoLock.lockFile = ../Cargo.lock;
# Disable tests since they can't run on WASM
doCheck = false;
# Required dependencies for WASM builds
depsBuildBuild = [
buildPackages.stdenv.cc
lld # Needed for wasm-ld
];
cargoBuildFlags = [
"--lib"
"--features"
"wasm-bindgen"
];
# Configure rustc for WASM
env = {
RUSTFLAGS = ''--cfg=web_sys_unstable_apis -C linker=wasm-ld'';
};
# Copy the WASM file to the output
installPhase = ''
mkdir -p $out/lib
cp target/wasm32-unknown-unknown/release/*.wasm $out/lib/
'';
}