build(flake): split into flake modules

This commit is contained in:
2026-09-06 16:39:29 +02:00
parent 46e977acf5
commit 5ea156c181
9 changed files with 216 additions and 189 deletions
+39 -31
View File
@@ -1,39 +1,47 @@
{
rustPlatform,
buildPackages,
lld,
name ? "wordle-solver",
...
}:
rustPlatform.buildRustPackage {
inherit name;
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;
src = ../.; # Or your source location
cargoLock.lockFile = ../Cargo.lock;
# Disable tests since they can't run on WASM
doCheck = false;
# 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
];
# Required dependencies for WASM builds
depsBuildBuild = [
buildPackages.stdenv.cc
lld # Needed for wasm-ld
];
cargoBuildFlags = [
"--lib"
"--features"
"wasm-bindgen"
];
cargoBuildFlags = [
"--lib"
"--features"
"wasm-bindgen"
];
# Configure rustc for WASM
env = {
RUSTFLAGS = ''--cfg=web_sys_unstable_apis -C linker=wasm-ld'';
# 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 {};
};
# Copy the WASM file to the output
installPhase = ''
mkdir -p $out/lib
cp target/wasm32-unknown-unknown/release/*.wasm $out/lib/
'';
}