48 lines
1.1 KiB
Nix
48 lines
1.1 KiB
Nix
{
|
|
perSystem = {pkgs, ...}: let
|
|
utils = import ./utils.nix;
|
|
toolchain-crosspkgs = utils.toolchain-crosspkgs pkgs;
|
|
drv = {
|
|
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/
|
|
'';
|
|
};
|
|
in {
|
|
packages.wordle-solver-wasm = toolchain-crosspkgs.callPackage drv {};
|
|
};
|
|
}
|