Skip to content

Commit

Permalink
Make cross compiling work with vendoring
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Aug 14, 2024
1 parent e4cec57 commit d278efb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions codecs/resize/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions codecs/resize/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,19 @@
];
src = ./.;

rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};

cargoLockFile = "${src}/Cargo.lock";

vendor = rustPlatform.importCargoLock {
lockFile = cargoLockFile;
};

wasm-bindgen-bin = wasm-bindgen.lib.buildFromCargoLock {
inherit system;
cargoLockFile = "${src}/Cargo.lock";
inherit system cargoLockFile;
sha256 = "sha256-HTElSB76gqCpDu8S0ZJlfd/S4ftMrbwxFgJM9OXBRz8=";
};
in
Expand All @@ -52,7 +62,11 @@
buildPhase = ''
runHook preBuild
export CARGO_HOME=$TMPDIR/.cargo
cargo build --target wasm32-unknown-unknown -r
cargo build \
--config 'source.crates-io.replace-with="vendored-sources"' \
--config 'source.vendored-sources.directory="${vendor}"' \
--offline \
--target ${target} -r
wasm-bindgen --target web --out-dir $out ./target/wasm32-unknown-unknown/release/*.wasm
runHook postBuild
'';
Expand Down

0 comments on commit d278efb

Please sign in to comment.