Skip to content

chore(nix): wasm32-wasip2 toolchain groundwork (hu stack 1/9)#232

Open
YuanYuYuan wants to merge 3 commits into
mainfrom
dev/pr-hu-1a-nix
Open

chore(nix): wasm32-wasip2 toolchain groundwork (hu stack 1/9)#232
YuanYuYuan wants to merge 3 commits into
mainfrom
dev/pr-hu-1a-nix

Conversation

@YuanYuYuan

Copy link
Copy Markdown
Collaborator

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: introduces rustToolchainWasm (the existing pure-Rust toolchain plus the wasm32-wasip2 target) and wires it into the pureRust-ci shell so CI can build the WASM plugins inline, plus a new pureRust-wasm dev 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 default pureRust shell 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, or RUSTFLAGS for normal cargo invocations.
  • .gitignore: ignore local .cargo/ state while keeping the committed config.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 the wasm32-wasip2 target 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 current dev/pr-hu-1-skeleton exactly.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a pureRust-wasm dev 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 pinned nix-ros-overlay.
  • Add a Cargo alias and adjust .gitignore to ignore local .cargo/* while keeping committed config; bump flake.lock and add crane.

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.

Comment thread .cargo/config.toml
Comment thread flake.nix
Comment thread flake.nix Outdated
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (and packages.default) that builds -p hiroz-union --bin hu, but this repo state doesn’t contain a hiroz-union crate or a hu binary yet (only crates/hiroz-console exists). As a result, nix build .#hu / nix build will 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-plugins currently points at crates/hiroz-union/plugins/Cargo.toml, but that manifest (and the hiroz-union workspace) 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"

Comment thread flake.nix Outdated
Comment thread flake.nix Outdated
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-plugins alias points at crates/hiroz-union/plugins/Cargo.toml, but that path does not exist in the current workspace (and hiroz-union is not a workspace member yet). As-is, cargo hu-plugins will 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 contains hiroz-console, not hiroz-union). This makes the new packages.hu output non-buildable on this branch.
              cargoExtraArgs = "-p hiroz-union --bin hu";

Comment thread flake.nix
Comment on lines +401 to 405
# Generate shells for available distros only
allDistroShells = builtins.listToAttrs (
builtins.map (distro: {
name = distro;
value = mkRosShells distro;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants