nix-rust-leptos

Standardize Leptos CSR builds with Nix, Crane, and Trunk.

10|1|Updated Mar 12, 2026
One-click install
npx skills add https://github.com/juspay/AI --skill nix-rust-leptos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nix-rust-leptos
Source: https://github.com/juspay/AI/tree/main/.opencode/skills/nix-rust-leptos
Command: npx skills add https://github.com/juspay/AI --skill nix-rust-leptos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Conventions for building Leptos CSR apps with Nix (crane + Trunk). This guide standardizes the production build workflow and tooling integration to reduce setup time and errors across teams.

Core Features & Use Cases

  • Trunk-based production builds: Use craneLib.buildTrunkPackage to manage wasm compilation, wasm-bindgen, wasm-opt, Tailwind CSS, asset hashing, SRI, and cross-reference rewriting.
  • Workspace guidance: Run from the crate directory or use postUnpack to target the client crate in a workspace.
  • Source filtering: Preserve HTML, CSS, and JS in the source filter to keep frontend assets intact during packaging.
  • Tailwind CSS integration: Include Tailwind CSS in nativeBuildInputs and use the data-trunk tailwind hook.
  • JS interop patterns: Use a dedicated bridge.rs for non-Leptos JS helpers and prefer leptos-use for browser APIs with safe cleanup.

Quick Start

Initialize a Leptos CSR project with Nix and Crane, then run the Trunk-based build to produce a production-ready client bundle.

Frequently Asked Questions about nix-rust-leptos

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Leptos CSR app with Nix and Trunk?

To build a Leptos CSR app with Nix and Trunk, use craneLib.buildTrunkPackage to manage WASM compilation, wasm-bindgen, wasm-opt, asset hashing, and SRI. This standardizes the production build pipeline and reduces setup errors across teams by integrating the tooling consistently.

What's the best way to handle Tailwind CSS in a Leptos Trunk build using Nix?

The best way to handle Tailwind CSS in a Leptos Trunk build is to include Tailwind CSS in nativeBuildInputs and use the data-trunk tailwind hook. This integrates the CSS framework directly into the Trunk-based packaging workflow managed by Crane.

How does JS interop work in a Leptos CSR app built with Nix?

JS interop in a Leptos CSR app built with Nix is handled through a dedicated bridge.rs file for non-Leptos JS helpers. For browser APIs, prefer leptos-use to ensure safe cleanup and seamless integration within the WASM package.

Can I use Crane to build a Leptos client crate inside a Nix workspace?

Yes, you can use Crane to build a Leptos client crate inside a Nix workspace by running the build from the crate directory or using postUnpack to target the client crate specifically, ensuring correct workspace setup and module integration.

Why does my Trunk packaging fail to include frontend assets in Nix?

Trunk packaging fails to include frontend assets in Nix when the source filter does not preserve HTML, CSS, and JS files. You must adjust the source filter to keep these frontend assets intact during the WASM packaging and build process.

Does buildTrunkPackage handle WASM optimization and asset hashing automatically?

Yes, buildTrunkPackage handles WASM optimization and asset hashing automatically. It manages wasm compilation, wasm-bindgen, wasm-opt, Tailwind CSS, asset hashing, SRI, and cross-reference rewriting for production-grade builds.