Skip to content

feat: Add Nix flake for reproducible builds#94

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

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

Conversation

@antono
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Contributor 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.

@bartolli
Copy link
Copy Markdown
Owner

Squash-merged with onnxruntime version comments. Thanks @antono

@bartolli bartolli closed this Mar 25, 2026
bartolli added a commit that referenced this pull request Mar 25, 2026
Adds flake.nix with naersk-based Rust build, devShell with rust-analyzer,
and nix run support. Includes onnxruntime version compatibility warnings.

Co-authored-by: Anton Vasiljev <antono.vasiljev@gmail.com>
bartolli added a commit that referenced this pull request Mar 25, 2026
- Remote embedding backend: OpenAI-compatible HTTP via CODANNA_EMBED_URL (PR #97)
- Bearer auth via CODANNA_EMBED_API_KEY env var (secrets not in config files)
- Dimension mismatch detection guards semantic index from silent replacement
- --force with CLI paths warns about configured roots that will not be rebuilt
- GetIndexInfoRequest schema includes properties:{} for OpenAI compatibility (PR #96)
- Nix flake for reproducible builds and nix run support (PR #94)
- Highlight range overlap panic fixed in document search
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