explaingit

anthropics/cargo-nix-plugin

Analysis updated 2026-06-24

13RustAudience · developerComplexity · 4/5Setup · hard

TLDR

A Nix plugin that makes Rust builds fully reproducible by reading Cargo.lock directly via a built-in resolveCargoWorkspace function, replacing large generated dependency files and adding cached Clippy lint support.

Mindmap

mindmap
  root((repo))
    What it does
      Nix plugin for Rust builds
      Reads Cargo.lock directly
      Reproducible by design
    Key Feature
      resolveCargoWorkspace
      No cargo needed
      Minimal index fetching
    Offline Builds
      Pre-generated metadata
      cargo-nix-prefetch tool
      Local index cache
    Linting and Tests
      Cached Clippy checks
      Deps compiled once
      Integration test support
    Constraint
      Must match Nix version
      Keep versions in sync
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build Rust projects inside Nix with full reproducibility without maintaining a large generated dependency file.

USE CASE 2

Run cached Clippy lint checks so only your own code is re-analyzed, not the entire dependency tree.

USE CASE 3

Pre-fetch the crates.io index on a connected machine so Rust builds work in network-isolated environments.

USE CASE 4

Run Rust integration tests through the Nix build interface with support for compiled binary invocations.

What is it built with?

RustNixcrates.io

How does it compare?

anthropics/cargo-nix-pluginlily-protocol/lily-contractsnhodges/yt-dlv
Stars131313
LanguageRustRustRust
Setup difficultyhardhardmoderate
Complexity4/54/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Must be compiled against the exact same Nix version that loads it, version mismatches break the plugin silently.

No license information is mentioned in the explanation.

In plain English

cargo-nix-plugin is a plugin for the Nix package manager that makes it easier to build Rust projects reproducibly. Nix is a build system focused on making builds fully deterministic: the same inputs always produce the same outputs, with no hidden dependencies. When you want to build a Rust project inside Nix, you need to tell Nix about all the dependencies Cargo manages, which has traditionally required generating a large intermediate file that describes the full dependency graph. This plugin replaces that approach. Instead of generating a file with tens of thousands of lines, the plugin adds a built-in function to Nix called resolveCargoWorkspace that reads your Cargo.lock file directly and fetches the minimal amount of information it needs from the crates.io package index, without requiring the cargo tool itself to be installed. It returns dependency information in a format Nix already knows how to use to compile Rust code. You can also pass pre-generated metadata from cargo if your build environment does not have network access, or pre-populate the index cache on a connected machine using a companion tool called cargo-nix-prefetch and then point the plugin at that local cache. Beyond basic builds, the plugin includes support for cached Clippy checks. Clippy is a Rust linting tool that checks your code for common mistakes. The plugin compiles dependencies once and caches them in the Nix store, so re-running Clippy only processes your own code rather than every library you depend on. Tests can also be run through the same interface, with support for integration tests that invoke compiled binaries. The plugin requires that it be compiled against the same version of Nix that loads it, so keeping versions in sync matters when upgrading.

Copy-paste prompts

Prompt 1
I have a Rust project with a Cargo.lock file and I want to build it inside Nix using cargo-nix-plugin. Write me a minimal flake.nix that calls resolveCargoWorkspace and produces the compiled binary.
Prompt 2
How do I set up cached Clippy checks with cargo-nix-plugin so that changing one file in my Rust project doesn't re-lint all its dependencies from scratch?
Prompt 3
My Nix build environment has no internet access. How do I use cargo-nix-prefetch to pre-populate the crates.io index cache so cargo-nix-plugin can resolve dependencies offline?
Prompt 4
What breaks if I upgrade Nix but forget to recompile cargo-nix-plugin against the new version? How do I make sure the versions stay in sync in a flake?
Prompt 5
How do I configure integration tests that invoke compiled binaries inside a cargo-nix-plugin Nix build?

Frequently asked questions

What is cargo-nix-plugin?

A Nix plugin that makes Rust builds fully reproducible by reading Cargo.lock directly via a built-in resolveCargoWorkspace function, replacing large generated dependency files and adding cached Clippy lint support.

What language is cargo-nix-plugin written in?

Mainly Rust. The stack also includes Rust, Nix, crates.io.

What license does cargo-nix-plugin use?

No license information is mentioned in the explanation.

How hard is cargo-nix-plugin to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is cargo-nix-plugin for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.