feat: add Nix flake for reproducible builds#110
Conversation
|
Hi @paolino 👋 Let us know when this is ready by moving this PR to "Ready", we'll assign a reviewer to it. |
|
Thanks! I'll have a look |
There was a problem hiding this comment.
Pull request overview
Adds first-class Nix support to make Blaster builds, checks, and development reproducible across supported systems, including a CI workflow to run nix flake check.
Changes:
- Introduces a
flake.nix/flake.lockdefining build outputs, checks (including a smoke test), and a dev shell with pinned Lean/Z3. - Adds direnv integration (
.envrc) and updates.gitignorefor common Nix/direnv artifacts. - Documents Nix usage in
README.mdand adds a GitHub Actions workflow to runnix flake check.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
flake.nix |
Defines Nix flake outputs: library build, wrapped z3check, test builds, smoke-check, and dev shell. |
flake.lock |
Pins nixpkgs, flake-parts, and lean4-nix inputs for reproducibility. |
.envrc |
Enables direnv to load the flake dev shell. |
.gitignore |
Ignores Nix build outputs and direnv artifacts. |
README.md |
Adds documentation for Nix-based development/build/check workflows. |
.github/workflows/ci-nix.yaml |
Adds manual CI job running nix flake check. |
tests/nix/TestBlaster.lean |
Adds a small Lean smoke test to ensure blaster works under Nix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ... | ||
| }: let | ||
| leanPkgs = pkgs.lean; | ||
| src = pkgs.lib.cleanSource ./.; |
There was a problem hiding this comment.
src = pkgs.lib.cleanSource ./.; does not respect .gitignore, so local build artifacts (e.g. .lake/, result*, .direnv/) can get captured into the Nix source, breaking reproducibility and potentially slowing builds. Consider switching to cleanSourceWith (or a fileset) with an explicit filter that excludes these directories/files.
| src = pkgs.lib.cleanSource ./.; | |
| src = pkgs.lib.cleanSourceWith { | |
| src = ./.; | |
| filter = path: type: | |
| pkgs.lib.cleanSourceFilter path type | |
| && let | |
| baseName = builtins.baseNameOf (toString path); | |
| in | |
| baseName != ".lake" | |
| && baseName != ".direnv" | |
| && !(pkgs.lib.hasPrefix "result" baseName); | |
| }; |
There was a problem hiding this comment.
Fixed in 2009c2b — switched to cleanSourceWith filtering out .lake, .direnv, and result*.
mpetruska
left a comment
There was a problem hiding this comment.
Works perfectly. (Tested on Arch, kernel: 6.19.12, nix: 2.34.6)
Only a minor request.
| result | ||
| result-* | ||
| .direnv/ | ||
| WIP.md No newline at end of file |
There was a problem hiding this comment.
I think this should not be added in .gitignore . (I mean the WIP.md file.)
There was a problem hiding this comment.
@paolino I'd like to humbly request to put local work-files (WIP.md) in the local gitignore (.git/info/exclude).
- ci-nix workflow: builds library, z3check, and runs blaster tactic - tests/nix/TestBlaster.lean: propositional, arithmetic, De Morgan
- Document nix develop, nix build, nix flake check usage - Change ci-nix trigger from pull_request to workflow_dispatch - Simplify ci-nix to just run nix flake check
cleanSource alone captures local build artifacts into the Nix store, breaking reproducibility. Filter them out via cleanSourceWith.
Add a Nix flake for reproducible builds, testing, and development.
What it provides
nix build— compiles the Blaster library with-O3nix build .#z3check— builds the z3check executable with Z3 4.15.2 in PATHnix develop— dev shell with Lean 4.24.0, Lake, elan, and Z3 4.15.2 (works with VS Code Lean 4 extension on NixOS via direnv)nix flake check— builds library, z3check, and the full test suiteKey details
lean-toolchainvia lean4-nixoverrideBuildModAttrs.envrcincluded for direnv integrationci-nixworkflow (manual dispatch) runsnix flake checkon ubuntu-latestFiles
flake.nixflake.lock.envrc.gitignoreresult,.direnv/README.md.github/workflows/ci-nix.yamltests/nix/TestBlaster.lean