chore(nix): wasm32-wasip2 toolchain groundwork (hu stack 1/9)#232
chore(nix): wasm32-wasip2 toolchain groundwork (hu stack 1/9)#232YuanYuYuan wants to merge 3 commits into
Conversation
Introduces the pureRust-wasm and pureRust-ci dev shells (rustToolchainWasm adds the wasm32-wasip2 sysroot, fetched only when those shells are entered) and a `cargo hu-plugins` alias, in preparation for the hu WASM plugin host. The default pureRust shell is unchanged and does not fetch the wasm sysroot.
There was a problem hiding this comment.
Pull request overview
Introduces Nix + Cargo configuration groundwork for upcoming hu WASM plugin work by adding a WASM-capable Rust toolchain option and related dev/CI shells, plus a few quality-of-life and caching-oriented updates.
Changes:
- Extend the Rust toolchain options with a
wasm32-wasip2-enabled variant and add apureRust-wasmdev shell; wire the WASM toolchain into CI-oriented shells. - Improve ROS shell env construction (per-package
AMENT_PREFIX_PATH) and restrict generated per-distro shells to distros present in the pinnednix-ros-overlay. - Add a Cargo alias and adjust
.gitignoreto ignore local.cargo/*while keeping committed config; bumpflake.lockand addcrane.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| flake.nix | Adds WASM-capable Rust toolchain/shells, per-package AMENT prefix handling, and introduces crane-based packaging. |
| flake.lock | Adds crane input and bumps pinned Nix inputs. |
| .gitignore | Ignores local .cargo/* while keeping .cargo/config.toml committed. |
| .cargo/config.toml | Adds a cargo hu-plugins convenience alias for the upcoming plugin workspace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot review: when AMENT_PREFIX_PATH is unset/empty, the
$AMENT_PREFIX_PATH:<paths> form injects a leading empty path segment, which
tools that split on ':' interpret as the current directory. Use
${AMENT_PREFIX_PATH:+...} so the existing value (and its separator) is only
prepended when non-empty.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
flake.nix:595
- The flake now defines a
packages.hu(andpackages.default) that builds-p hiroz-union --bin hu, but this repo state doesn’t contain ahiroz-unioncrate or ahubinary yet (onlycrates/hiroz-consoleexists). As a result,nix build .#hu/nix buildwill fail when invoked, which undermines the goal of this PR being independently green groundwork.
nativeBuildInputs = [
pkgs.pkg-config
pkgs.protobuf
];
cargoExtraArgs = "-p hiroz-union --bin hu";
doCheck = false;
.cargo/config.toml:7
cargo hu-pluginscurrently points atcrates/hiroz-union/plugins/Cargo.toml, but that manifest (and thehiroz-unionworkspace) is not present in this PR. This makes the new alias fail immediately if used, and the comment also references a docs file that isn’t in-tree yet.
# Build the hu WASM plugins (meter + monitor) from the repo root without
# remembering the manifest path and target. Append --release for an optimized
# build. See docs/tools/hu-plugins.md.
hu-plugins = "build --manifest-path crates/hiroz-union/plugins/Cargo.toml --target wasm32-wasip2 --workspace"
Reword the wasm shell banner to not instruct 'cargo hu-plugins' (unusable in this PR) and correct the AMENT_PREFIX_PATH comment which wrongly claimed multiple statements increment SHLVL.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
.cargo/config.toml:7
- The new
hu-pluginsalias points atcrates/hiroz-union/plugins/Cargo.toml, but that path does not exist in the current workspace (andhiroz-unionis not a workspace member yet). As-is,cargo hu-pluginswill fail immediately from the repo root.
# Build the hu WASM plugins (meter + monitor) from the repo root without
# remembering the manifest path and target. Append --release for an optimized
# build. See docs/tools/hu-plugins.md.
hu-plugins = "build --manifest-path crates/hiroz-union/plugins/Cargo.toml --target wasm32-wasip2 --workspace"
flake.nix:595
cargoExtraArgs = "-p hiroz-union --bin hu"references a workspace package that does not exist in this PR (the workspace currently containshiroz-console, nothiroz-union). This makes the newpackages.huoutput non-buildable on this branch.
cargoExtraArgs = "-p hiroz-union --bin hu";
| # Generate shells for available distros only | ||
| allDistroShells = builtins.listToAttrs ( | ||
| builtins.map (distro: { | ||
| name = distro; | ||
| value = mkRosShells distro; |
Summary
First of a stacked series splitting the large
hu(hiroz-union) skeleton PR (#231) into small, individually-reviewable, individually-green pieces. This PR carries only the Nix toolchain groundwork the later plugin work needs — no crates, no CLI, no behavior change.Key Changes
flake.nix: introducesrustToolchainWasm(the existing pure-Rust toolchain plus thewasm32-wasip2target) and wires it into thepureRust-cishell so CI can build the WASM plugins inline, plus a newpureRust-wasmdev shell for building plugins locally with the full dev toolchain. The wasm sysroot (~100–500 MB) is fetched only when a wasm-capable shell is entered; the defaultpureRustshell is unchanged and stays lean..cargo/config.toml: adds a single[alias]entry,cargo hu-plugins, as a convenience for building the plugin workspace. It changes no build flags, targets, orRUSTFLAGSfor normalcargoinvocations..gitignore: ignore local.cargo/state while keeping the committedconfig.toml.flake.lock: routine input bump.What fails without this
Nothing yet — this is groundwork. The later child PRs (plugin host,
hu-meter/hu-monitor, WASM plugin CI job) require thewasm32-wasip2target to be available in the CI shell; this PR makes it available without changing any current build.Breaking Changes
None.
Stacked PR series
This is PR 1 of 9. Base:
main. Subsequent children stack on this branch. The tip of the stack reconstructs the currentdev/pr-hu-1-skeletonexactly.