Conversation
Flake lock file updates:
• Updated input 'nix':
'github:DeterminateSystems/nix-src/370987f' (2026-01-23)
→ 'github:DeterminateSystems/nix-src/c9f71f3' (2026-02-06)
📝 WalkthroughWalkthroughIntroduces WASI plugin infrastructure for nix-wasm-rust by adding a wasi workspace with multi-system Nix flake, a nix-wasi-plugin-fib binary that invokes fib and returns results to the Nix host, extending the Value API with from_id and return_to_nix methods, updating CI to validate the wasi flake, and adding build configuration entries. Changes
Sequence DiagramsequenceDiagram
actor Nix Host
participant nix-wasi-plugin-fib Binary
participant nix-wasm-plugin-fib Crate
participant Value API
Nix Host->>nix-wasi-plugin-fib Binary: Invoke with ValueId argument
nix-wasi-plugin-fib Binary->>nix-wasi-plugin-fib Binary: Parse argv[1] to ValueId
nix-wasi-plugin-fib Binary->>Value API: Value::from_id(id)
Value API-->>nix-wasi-plugin-fib Binary: Return Value
nix-wasi-plugin-fib Binary->>nix-wasm-plugin-fib Crate: fib(value)
nix-wasm-plugin-fib Crate-->>nix-wasi-plugin-fib Binary: Return result
nix-wasi-plugin-fib Binary->>Value API: result.return_to_nix()
Value API->>Nix Host: return_to_nix(value_id) [never returns]
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
wasi/flake.nix (2)
75-82: Consider sourcing dev tools from the fenix toolchain for consistency.The devShell references
rust-analyzer,rustfmt, andclippyfrompkgs, but the build uses a custom toolchain fromfenix. This could lead to version mismatches between the tools used during development and the actual build toolchain.♻️ Proposed fix to use fenix toolchain components
devShells = forAllSystems ({ pkgs, system }: rec { - default = with pkgs; self.packages.${system}.default.overrideAttrs (attrs: { + default = self.packages.${system}.default.overrideAttrs (attrs: { nativeBuildInputs = attrs.nativeBuildInputs ++ [ - rust-analyzer - rustfmt - clippy + inputs.fenix.packages.${system}.latest.rust-analyzer + inputs.fenix.packages.${system}.latest.rustfmt + inputs.fenix.packages.${system}.latest.clippy ]; }); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@wasi/flake.nix` around lines 75 - 82, The devShells block adds rust-analyzer, rustfmt, and clippy from pkgs which can mismatch the fenix toolchain; update the devShells (forAllSystems / default / nativeBuildInputs override) to source these tools from the fenix toolchain instead of pkgs (e.g., use the fenix package set or toolchain attribute you already instantiate) so rust-analyzer, rustfmt, and clippy come from the same fenix toolchain used for builds.
26-26:supportedSystemsexcludesaarch64-linuxandx86_64-darwin.The current list only includes
aarch64-darwinandx86_64-linux. If this is intentional (e.g., due to toolchain or runtime limitations), consider adding a comment explaining why. Otherwise, expanding coverage would improve cross-platform support.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@wasi/flake.nix` at line 26, supportedSystems currently lists only "aarch64-darwin" and "x86_64-linux", excluding "aarch64-linux" and "x86_64-darwin"; either add the missing system identifiers to the supportedSystems array in wasi/flake.nix (include "aarch64-linux" and "x86_64-darwin") to broaden platform support, or if their exclusion is intentional, add a brief inline comment next to the supportedSystems declaration explaining why those platforms are omitted (e.g., toolchain/runtime limitations or untested targets) so reviewers understand the rationale.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@wasi/nix-wasi-plugin-fib/src/main.rs`:
- Around line 25-30: The code currently indexes args[1] which panics if no CLI
argument is provided; change the logic that builds the Value from argv to safely
access the second argument (use env::args().collect() then args.get(1)) and
return or panic with a descriptive message if it's missing, then parse that &str
to u32 as before and pass into Value::from_id; update the logic around
parse::<u32>() to propagate or format parse errors with a clear message
mentioning the expected ValueId/argument.
---
Nitpick comments:
In `@wasi/flake.nix`:
- Around line 75-82: The devShells block adds rust-analyzer, rustfmt, and clippy
from pkgs which can mismatch the fenix toolchain; update the devShells
(forAllSystems / default / nativeBuildInputs override) to source these tools
from the fenix toolchain instead of pkgs (e.g., use the fenix package set or
toolchain attribute you already instantiate) so rust-analyzer, rustfmt, and
clippy come from the same fenix toolchain used for builds.
- Line 26: supportedSystems currently lists only "aarch64-darwin" and
"x86_64-linux", excluding "aarch64-linux" and "x86_64-darwin"; either add the
missing system identifiers to the supportedSystems array in wasi/flake.nix
(include "aarch64-linux" and "x86_64-darwin") to broaden platform support, or if
their exclusion is intentional, add a brief inline comment next to the
supportedSystems declaration explaining why those platforms are omitted (e.g.,
toolchain/runtime limitations or untested targets) so reviewers understand the
rationale.
|
|
||
| inputs = { | ||
| nixpkgs.follows = "nix/nixpkgs"; | ||
| flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz"; |
There was a problem hiding this comment.
I think we generally leave off the .tar.gz and opt for not using * in versions
This shows how to build a Nix Wasm function using WASI, i.e. compiled with system type
wasm32-wasip1instead ofwasm32-unknown-unknown.It depends on DeterminateSystems/nix-src#359.
Example usage:
Summary by CodeRabbit
New Features
Chores