build: add docker images

This commit is contained in:
2026-09-08 17:34:07 +02:00
parent 5ea156c181
commit 9b34a045fa
4 changed files with 124 additions and 5 deletions
+12 -3
View File
@@ -1,12 +1,14 @@
{
perSystem = {pkgs, ...}: let
utils = import ./utils.nix;
rust-toolchain = utils.rust-toolchain pkgs;
toolchain-crosspkgs = utils.toolchain-crosspkgs pkgs;
drv = {
rustPlatform,
buildPackages,
lld,
name ? "wordle-solver",
removeReferencesTo,
...
}:
rustPlatform.buildRustPackage {
@@ -23,6 +25,7 @@
buildPackages.stdenv.cc
lld # Needed for wasm-ld
];
nativeBuildInputs = [removeReferencesTo];
cargoBuildFlags = [
"--lib"
@@ -31,17 +34,23 @@
];
# Configure rustc for WASM
env = {
RUSTFLAGS = ''--cfg=web_sys_unstable_apis -C linker=wasm-ld'';
};
RUSTFLAGS = ''--cfg=web_sys_unstable_apis -C linker=wasm-ld -C strip=debuginfo -C debuginfo=0'';
# Copy the WASM file to the output
installPhase = ''
mkdir -p $out/lib
cp target/wasm32-unknown-unknown/release/*.wasm $out/lib/
runHook postInstall
'';
# Remove toolchain from closure (store paths are debug artifacts)
postInstall = ''
remove-references-to -t ${rust-toolchain} $out/lib/*.wasm
'';
};
in {
packages.toolchain = rust-toolchain;
packages.wordle-solver-wasm = toolchain-crosspkgs.callPackage drv {};
};
}