Files
rust-overlay/examples/cross-wasi/shell.nix
oxalica 06871d5c5f {rust-bin,example}: remove WASI target workaround and fix example
The un-versioned `wasm32-wasi` target is removed in favor of
`wasm32-wasip?` since Rust 1.84. Examples are updated.

The nixpkgs patch for WASI target name remapping is merged in 24.11.
We can also safely remove the workaround.
2025-01-11 13:09:47 +08:00

33 lines
1.1 KiB
Nix

# See docs/cross_compilation.md for details.
(import <nixpkgs> {
crossSystem = {
config = "wasm32-wasi";
# NB. Rust use a different naming convention for target platforms and
# differentiates multiple version of WASI specification by using "wasip?".
# If this line is omitted, `wasm32-wasip1` (WASI 0.1) is assumed.
# See: <https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html>
#
# If you changed this, also update `CARGO_TARGET_*_RUNNER` below.
rust.rustcTarget = "wasm32-wasip1";
# Nixpkgs currently only supports LLVM lld linker for wasm32-wasi.
useLLVM = true;
};
overlays = [ (import ../..) ];
}).callPackage (
# We don't need WASI C compiler from nixpkgs, so use `mkShellNoCC`.
{ mkShellNoCC, stdenv, rust-bin, wasmtime }:
mkShellNoCC {
nativeBuildInputs = [ rust-bin.stable.latest.minimal ];
depsBuildBuild = [ wasmtime ];
# This is optional for wasm32-like targets, since rustc will automatically use
# the bundled `lld` for linking.
# CARGO_TARGET_WASM32_WASIP1_LINKER =
CARGO_TARGET_WASM32_WASIP1_RUNNER = "wasmtime run";
}) {}