AI SummaryThis Cursor rule enforces best practices for Rust development on Nix and NixOS, including documentation-first workflows, library version management, and proper build toolchain usage. It's essential for developers working with Rust, Bevy, or EGUI in Nix-based environments.
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to add the "alchemist — Cursor Rules" prompt rules to my project. Repository: https://github.com/TheCowboyAI/alchemist Please read the repo to find the rules/prompt file, then: 1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type) 2. If there's an existing rules file, merge the new rules in rather than overwriting 3. Confirm what was added
Description
Rules for Rust on Nix and NixOS
Context
This rule ensures consistent and reproducible Rust toolchain and standard library setup in a NixOS environment, specifically for Bevy/Wayland applications using Nightly Rust 2024 edition.
1. Toolchain Management
• Use oxalica/rust-overlay with flake-parts: • Configure your flake to pull in rust-overlay and set up Nightly Rust with rust-src and rust-analyzer extensions. • Example: ` rust-nightly = (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { extensions = ["rust-src" "rust-analyzer"]; targets = ["x86_64-unknown-linux-gnu"]; } )); ` • Set RUST_SRC_PATH: • Export RUST_SRC_PATH in your shellHook to point to the Nightly Rust standard library. ` shellHook = '' export RUST_SRC_PATH="${rust-nightly}/lib/rustlib/src/rust/library" ''; `
2. Environment Setup
• Include required build inputs: • Add the following to buildInputs: ` buildInputs = with pkgs; [ vulkan-loader libxkbcommon wayland udev alsaLib pkg-config xorg.libX11 ]; ` • Set Wayland environment variables: • Add to your shellHook: ` export WINIT_UNIX_BACKEND=wayland export RUST_BACKTRACE=full `
3. Project Structure
• Follow Rust conventions: • Use src/ for source code, main.rs/lib.rs as entry points, bin/ for multiple binaries, tests/ for integration tests, and examples/ for example code[2]. • Use a workspace if multi-crate: • Structure your project as a workspace for modularity.
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster
Works With
Any AI assistant that accepts custom rules or system prompts