Skip to content

ImitationGameLabs/nix-rust-template

Repository files navigation

Nix Rust Template

A modern Rust workspace template using Nix + direnv + crane + rust-overlay. Ready to use out of the box.

Core Features

  • Reproducible builds - Nix flakes ensure reproducibility
  • Fast incremental builds - crane dependency caching speeds up CI
  • Workspace ready - Pre-configured multi-crate structure
  • Auto environment - nix-direnv automatic environment loading
  • CI ready - Built-in clippy, fmt, test, audit, deny checks
  • Deploy ready - Includes home-manager module examples

Project Structure

.
├── flake.nix              # Flake entry point
├── nix/
│   ├── common.nix         # Core config (crate paths, dependencies)
│   ├── packages.nix       # Flake output packages
│   └── dev/
│       ├── shell.nix      # Development environment
│       └── checks.nix     # CI checks
└── crates/                # Rust workspace

Quick Start

# Use as GitHub template, then clone your new repo

# Option 1: Manual dev shell
nix develop

# Option 2: direnv auto-loading (recommended)
direnv allow

# Build
nix build

# Run all checks
nix flake check

direnv Integration

The project includes .envrc for direnv automatic environment loading.

Installation:

Usage:

  1. Allow in project:

    direnv allow
  2. Dev shell activates automatically when entering the directory; IDEs recognize correct tool versions

CI Checks

nix flake check runs the following:

Check Description
*-clippy Lint (warnings as errors)
*-fmt Code format check
*-toml-fmt TOML format check
*-doc Doc build (warnings as errors)
*-nextest Test runner
*-audit Security audit
*-deny License and dependency checks

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages