Created
February 8, 2026 17:07
-
-
Save shift/3f8feb1b5f67dddf5cfbfe2d76d54de8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "Rust Agentic Environment (Nightly + Diagnostics Tracking)"; | |
| inputs = { | |
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
| flake-utils.url = "github:numtide/flake-utils"; | |
| # REQUIRED: The overlay to get the Nightly compiler | |
| rust-overlay.url = "github:oxalica/rust-overlay"; | |
| }; | |
| outputs = { self, nixpkgs, flake-utils, rust-overlay }: | |
| flake-utils.lib.eachDefaultSystem (system: | |
| let | |
| # Apply the overlay to nixpkgs | |
| overlays = [ (import rust-overlay) ]; | |
| pkgs = import nixpkgs { | |
| inherit system overlays; | |
| }; | |
| # --------------------------------------------------------------------- | |
| # NIGHTLY TOOLCHAIN | |
| # We need this specific version to access -Z flags. | |
| # We include 'rust-src' for rust-analyzer support. | |
| # --------------------------------------------------------------------- | |
| rustToolchain = pkgs.rust-bin.nightly.latest.default.override { | |
| extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ]; | |
| }; | |
| # --------------------------------------------------------------------- | |
| # 1. AGENT-CHECK (The Diagnostic Tracker) | |
| # --------------------------------------------------------------------- | |
| # -Z track-diagnostics: Debugs where the error was created. | |
| # --message-format short: Keeps it readable for the Agent. | |
| agentCheck = pkgs.writeShellScriptBin "agent-check" '' | |
| echo "π¦ [Check] Verifying Syntax (Nightly Diagnostics)..." | |
| ${rustToolchain}/bin/cargo check \ | |
| -Z track-diagnostics \ | |
| --message-format short \ | |
| --color never \ | |
| --quiet | |
| ''; | |
| # --------------------------------------------------------------------- | |
| # 2. AGENT-LINT (Nightly Clippy) | |
| # --------------------------------------------------------------------- | |
| agentLint = pkgs.writeShellScriptBin "agent-lint" '' | |
| echo "π§Ή [Lint] Running Nightly Clippy..." | |
| ${rustToolchain}/bin/cargo clippy \ | |
| --message-format short \ | |
| --color never \ | |
| -- \ | |
| -D warnings \ | |
| -D clippy::unwrap_used \ | |
| -D unsafe_code | |
| ''; | |
| # --------------------------------------------------------------------- | |
| # 3. AGENT-AUDIT (Security) | |
| # --------------------------------------------------------------------- | |
| agentAudit = pkgs.writeShellScriptBin "agent-audit" '' | |
| echo "π [Audit] Scanning dependencies..." | |
| ${pkgs.cargo-audit}/bin/cargo-audit --color never | |
| ''; | |
| # --------------------------------------------------------------------- | |
| # AGENT CONTEXT | |
| # --------------------------------------------------------------------- | |
| agentContext = '' | |
| # Rust Agent Protocol (Nightly Edition) | |
| ## π NIGHTLY TOOLCHAIN ACTIVE | |
| You are using the **Nightly** compiler. | |
| - Syntax check uses \`-Z track-diagnostics\`. | |
| - If the compiler outputs internal path traces, focus on the "created at" location to understand the *root cause* of the error. | |
| ## π¨ STRICT GUARDRAILS | |
| 1. **NO \`Cargo.toml\` EDITS:** Use \`cargo add\`. | |
| 2. **NO UNWRAPS:** Panics are banned. | |
| 3. **NO UNSAFE:** Unsafe code is banned. | |
| ## π COMMANDS | |
| | Command | Purpose | Output Style | | |
| | :--- | :--- | :--- | | |
| | \`agent-check\` | **Deep Diagnostic Check.** | \`file:line:col: error\` + Diagnostic Trace | | |
| | \`agent-lint\` | **Security/Perf Check.** | Short format. | | |
| | \`agent-audit\` | **CVE Scan.** | Database output. | | |
| ''; | |
| in | |
| { | |
| devShells.default = pkgs.mkShell { | |
| buildInputs = [ | |
| rustToolchain # The Nightly Compiler | |
| pkgs.cargo-audit | |
| pkgs.pkg-config | |
| pkgs.openssl | |
| # Agent Scripts | |
| agentCheck | |
| agentLint | |
| agentAudit | |
| ]; | |
| shellHook = '' | |
| echo "π Initializing Rust Nightly Environment..." | |
| echo " (Enabled: -Z track-diagnostics)" | |
| echo "${agentContext}" > AGENT_CONTEXT.md | |
| # Configure sparse registry for speed | |
| mkdir -p .cargo | |
| echo '[registry]' > .cargo/config.toml | |
| echo 'default = "sparse"' >> .cargo/config.toml | |
| if [ ! -f Cargo.toml ]; then | |
| cargo init --quiet | |
| cargo add tokio --features full --quiet | |
| cargo add anyhow --quiet | |
| fi | |
| ''; | |
| }; | |
| } | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment