Add nix flake for dev shell and package build#136
Conversation
Provides a nix flake using crane + rust-overlay for building ethlambda and a development shell with Rust 1.92.0, clippy, rustfmt, and system dependencies (libclang, pkg-config). Includes direnv integration via .envrc and handles vergen-git2 env var fallback for nix builds where .git is absent.
🤖 Kimi Code ReviewThis PR adds Nix flake support for reproducible builds and development environments. The changes are configuration-only and don't affect consensus-critical code. Issues found:
Security considerations:
Performance implications:
The flake configuration appears well-structured and follows Nix best practices. Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewNo consensus-layer or Rust code changes in this PR. It only adds Nix/direnv tooling. I don’t see correctness, security, or performance risks for the client itself. If you want one minor maintainability note:
Otherwise looks good. Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewPR Review: Add nix flake for dev shell and package buildThis PR is purely tooling infrastructure — no consensus-layer or Rust source changes. The flake is well-structured and follows modern Nix/crane conventions. CorrectnessRust version consistency ( rustToolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;This also ensures the
Minor Issues
default = pkgs.mkShell {
inputsFrom = [ ethlambda ];
nativeBuildInputs = with pkgs; [ (rustToolchain pkgs) pkg-config cargo-watch ];
};This requires restructuring slightly (packages must be computed before devShells), but eliminates the duplication entirely and keeps both environments in lockstep automatically.
Kimi Bot Note CorrectionsThe Kimi review suggested adding SummaryThe flake is clean and correct. The main actionable item is reading from Automated review by Claude (Anthropic) · custom prompt |
Greptile SummaryIntroduces Nix flake infrastructure for reproducible development environments and builds, using crane for optimized Rust compilation and rust-overlay to pin Rust 1.92.0 matching
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| flake.nix | Adds Nix flake with crane-based Rust build, proper toolchain pinning (1.92.0), and cross-platform dev shell support |
| .envrc | Adds direnv integration for automatic dev shell activation |
| flake.lock | Pins nixpkgs, crane, and rust-overlay dependencies with proper hash verification |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[flake.nix] --> B{Output Type}
B -->|devShells.default| C[Dev Environment]
B -->|packages.default| D[Build Pipeline]
C --> C1[rust-overlay]
C1 --> C2[Rust 1.92.0 + clippy + rustfmt]
C2 --> C3[pkg-config + cargo-watch]
C3 --> C4[libclang + Darwin deps]
D --> D1[craneLib.cleanCargoSource]
D1 --> D2[buildDepsOnly]
D2 --> D3[Cache Dependencies]
D3 --> D4[buildPackage]
D4 --> D5[Set VERGEN_GIT_SHA/BRANCH]
D5 --> D6[ethlambda binary]
E[.envrc] -.->|direnv integration| C
F[flake.lock] -.->|pins versions| A
Last reviewed commit: a569142
Motivation
Provide a reproducible development environment and build via nix, so contributors can get a working setup with a single command regardless of their system package manager.
Description
Adds a nix flake using crane for Rust builds and rust-overlay to pin the exact Rust 1.92.0 toolchain.
Outputs
devShells.defaultpackages.defaultethlambdarelease binaryBuild structure
Crane's two-phase build (
buildDepsOnly→buildPackage) caches compiled dependencies separately from source code, giving fast incremental rebuilds similar to cargo-chef in Docker.vergen-git2 handling
Nix cleans the source tree, so
.gitis absent at build time. The flake setsVERGEN_GIT_SHA(from the flake's git rev) andVERGEN_GIT_BRANCH("nix") as env vars. vergen-git2 falls back to these when git info is unavailable.Platform support
Supports
x86_64-linux,aarch64-linux,x86_64-darwin, andaarch64-darwin. Darwin builds includelibiconvandapple-sdk_15; these are gated behindisDarwinand don't affect Linux.Files
flake.nix— flake definitionflake.lock— pinned input revisions.envrc— direnv integration (use flake)How to Test