원클릭으로
rust-devenv-setup
// Reproducible Nix-based Rust development environment setup with devenv, rust-overlay, clippy, rustfmt, and rust-analyzer.
// Reproducible Nix-based Rust development environment setup with devenv, rust-overlay, clippy, rustfmt, and rust-analyzer.
Packaging Node.js apps (npm/pnpm/bun) as Nix derivations. Use when creating buildNpmPackage expressions, fetchPnpmDeps-based derivations, or integrating JavaScript/TypeScript CLI tools into nix-darwin or NixOS configurations.
Reproducible Nix-based Python development environment setup with devenv, uv, ruff, and ty.
| name | rust-devenv-setup |
| description | Reproducible Nix-based Rust development environment setup with devenv, rust-overlay, clippy, rustfmt, and rust-analyzer. |
| user-invocable | false |
Set up a complete, reproducible Rust development environment using devenv and rust-overlay.
| Tool | Purpose |
|---|---|
| devenv | Nix-based declarative development environment |
| rust-overlay | Nix overlay for flexible Rust toolchain selection |
| clippy | Rust linter |
| rustfmt | Rust formatter |
| rust-analyzer | Rust LSP for IDE support |
| cbindgen | C header generation from Rust FFI crates (optional) |
Before running the setup script, gather parameters from the user using AskUserQuestion.
Cargo.toml package namestable2024volcap-ffi uses cdylib → add cbindgen)Use AskUserQuestion to confirm or adjust parameters. Ask all questions in a single call.
Example:
AskUserQuestion({
questions: [
{
question: "What is the project name?",
header: "Project",
options: [
{ label: "<inferred-name>", description: "Inferred from current directory" },
{ label: "custom", description: "Enter a different name" }
],
multiSelect: false
},
{
question: "Which Rust channel?",
header: "Rust Channel",
options: [
{ label: "stable (Recommended)", description: "Latest stable release" },
{ label: "nightly", description: "Nightly with unstable features" },
{ label: "beta", description: "Next stable candidate" }
],
multiSelect: false
},
{
question: "Extra packages needed?",
header: "Extras",
options: [
{ label: "None", description: "Base Rust toolchain only" },
{ label: "cbindgen", description: "C/C++ header generation for FFI crates" },
{ label: "cargo-nextest", description: "Faster test runner" },
{ label: "cargo-watch", description: "File watcher for auto-rebuild" }
],
multiSelect: true
}
]
})
setup.shBuild the command from the user's answers and execute.
After running the script, add the rust-overlay input:
cd "${TARGET_DIR}" && devenv inputs add rust-overlay github:oxalica/rust-overlay --follows nixpkgs
This step is required because devenv inputs add modifies devenv.yaml with a lock entry that cannot be templated.
setup.sh generates configuration files and directory structure.
| Variable | Description | Default |
|---|---|---|
PROJECT_NAME | Project name in kebab-case | Required |
RUST_CHANNEL | Rust toolchain channel (stable, nightly, beta) | stable |
EXTRA_PACKAGES | Space-separated extra nix packages (e.g. rust-cbindgen cargo-nextest) | (empty) |
TARGET_DIR | Output directory | Current directory |
# Basic setup
PROJECT_NAME="my-project" \
bash "${CLAUDE_PLUGIN_ROOT}/skills/rust-devenv-setup/setup.sh"
# With extras
PROJECT_NAME="my-ffi-lib" RUST_CHANNEL="stable" \
EXTRA_PACKAGES="rust-cbindgen" \
bash "${CLAUDE_PLUGIN_ROOT}/skills/rust-devenv-setup/setup.sh"
| File | Purpose |
|---|---|
devenv.yaml | Nix flake inputs (nixpkgs + rust-overlay) + cachix |
devenv.nix | Rust toolchain + extra packages |
.envrc | direnv integration for auto-activation |
Note: devenv.yaml is generated without the rust-overlay input lock. Run devenv inputs add rust-overlay ... after generation (Step 4).
After running the script:
# Add rust-overlay input (required for languages.rust.channel)
devenv inputs add rust-overlay github:oxalica/rust-overlay --follows nixpkgs
# Activate the environment
direnv allow
# Verify
rustc --version
cargo --version
use_devenv: command not found in direnvThe .envrc must contain eval "$(devenv direnvrc)" before use devenv. This is NOT a global direnv setting — it must be per-project.
languages.rust.channel requires rust-overlayWithout the rust-overlay input, devenv will error:
error: To use 'languages.rust.channel', run:
$ devenv inputs add rust-overlay github:oxalica/rust-overlay --follows nixpkgs
Some Rust tools have different names in nixpkgs:
| Tool | nixpkgs package name |
|---|---|
| cbindgen | pkgs.rust-cbindgen (NOT pkgs.cbindgen) |
| cargo-nextest | pkgs.cargo-nextest |
| cargo-watch | pkgs.cargo-watch |
Use nix search nixpkgs <keyword> to verify package names.
# Check devenv status
devenv info
# Run clippy
cargo clippy
# Check formatting
cargo fmt --check
# Build
cargo check
references/ffi-variants.md