build: add docker images
This commit is contained in:
@@ -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 {};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user