Skip to content

feat: Add Nix flake for reproducible builds#94

Open
antono wants to merge 4 commits intobartolli:mainfrom
antono:nix-flake
Open

feat: Add Nix flake for reproducible builds#94
antono wants to merge 4 commits intobartolli:mainfrom
antono:nix-flake

Conversation

@antono
Copy link

@antono antono commented Mar 16, 2026

Summary

  • Add Nix flake for reproducible builds and development environments
  • Add Nix installation option to README

Changes

Commits

  • ef90ea8 - Add flake.nix with naersk-based Rust build configuration
  • 5c59244 - Add Nix installation option to README
  • c464195 - Fix nix devshell environment

Details

flake.nix

  • Uses naersk for building Rust projects with Nix
  • Configures devShell with rust and rust-analyzer
  • Configures package output with openssl and onnxruntime dependencies
  • Sets ORT_SKIP_DOWNLOAD=1 to use pre-installed ONNX Runtime

README.md

  • Adds nix run github:bartolli/codanna as fourth installation option

Why Nix Flakes?

Nix flakes provide:

  • Reproducible environments - Team members get identical toolchains
  • Isolated builds - No "works on my machine" issues
  • Declarative config - Version-locked dependencies via flake.lock
  • Easy onboarding - nix run or nix develop gets you started instantly

This enables users to run codanna without installing Rust or managing dependencies manually.

antono added 3 commits March 16, 2026 16:04
- Add flake.nix with naersk-based Rust build configuration
- Add flake.lock for reproducible Nix dependencies

This enables `nix develop` for development shell and `nix build` for building the project.
- Add `nix run github:bartolli/codanna` to Quick Start section
- Lists as fourth installation option alongside curl, Homebrew, Windows
@bartolli
Copy link
Owner

Hi, thanks for adding Nix flake support.

Before merging, there are a few things worth addressing. The flake.lock currently pins three separate nixpkgs revisions because naersk (via fenix) and rust-overlay each bring their own. Using inputs.nixpkgs.follows = "nixpkgs" on those inputs would deduplicate them and reduce the closure size significantly.

The hardcoded version = "0.9.17" in flake.nix will drift on every release -- naersk reads the version from Cargo.toml automatically, so that line can just be removed.

The devShell should also set ORT_SKIP_DOWNLOAD = "1" as an env var (like the package build does), otherwise cargo build inside nix develop will try to download its own ONNX Runtime instead of using the Nix-provided one.

One thing I'd like to confirm, have you run nix build to completion? The project pins ort = "=2.0.0-rc.10" (ONNX Runtime 1.22) due to glibc constraints, and the nixpkgs onnxruntime package may be a different version. If the C API doesn't match, the build will compile but fail at runtime.

Also, result (the symlink nix build creates) should be added to .gitignore.

These should all be quick fixes. I'm not a Nix user myself, otherwise I'd have patched them directly. Thanks again for the contribution!

- Deduplicate nixpkgs using inputs.follows (3→1 revision)
- Remove hardcoded version (naersk reads from Cargo.toml)
- Add ORT_SKIP_DOWNLOAD=1 to devShell
- Add result symlinks to .gitignore
@antono
Copy link
Author

antono commented Mar 21, 2026

One thing I'd like to confirm, have you run nix build to completion? The project pins ort = "=2.0.0-rc.10" (ONNX Runtime 1.22) due to glibc constraints, and the nixpkgs onnxruntime package may be a different version. If the C API doesn't match, the build will compile but fail at runtime.

yes. it was built and works.
addressed other comments in my last commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants