Commit ee67062
authored
feat(nix): integrate uv2nix for Python dependency management (#88)
* feat(nix): integrate uv2nix for Python dependency management
Replace uv-managed .venv with Nix-managed Python environments using
uv2nix. This provides fully reproducible builds with dependencies
cached in the Nix store, eliminating the need for uv sync in CI.
Key changes:
- Add uv2nix, pyproject-nix, and pyproject-build-systems inputs
- Create devShells for Python 3.11 and 3.13 (default, python311, python313)
- Add build system overrides for pypika (setuptools) and stackone-ai (editables)
- Update CI matrix to use nix develop .#pythonXXX instead of uv sync
- Simplify setup-nix action with gc-max-store-size for cache management
- Add lint-fix alias to justfile
The .venv directory is no longer needed as all dependencies are
managed by Nix. Both Nix and non-Nix users can still use uv run
commands which will work in either environment.
* fix(ci): add python-version to cache key for parallel jobs
Separate cache keys per Python version to prevent cache overwrites
when matrix jobs run in parallel. Default to python311 since it
matches the default devShell.
* fix(nix): set VIRTUAL_ENV for ty to find site-packages
ty needs VIRTUAL_ENV to locate the Python environment's site-packages.
Without this, ty looks for .venv which doesn't exist in the Nix environment.
Also update justfile to conditionally use 'uv run' prefix only when
not in a Nix environment (detected via VIRTUAL_ENV). This makes
commands work for both Nix and non-Nix users.
* ci: add build-cache job to pre-build Nix environments
Add a dedicated build-cache job that runs before other CI jobs to
pre-populate the Nix store cache. This ensures that subsequent
parallel jobs (gitleaks, ci matrix, coverage) can benefit from the
cached derivations instead of each rebuilding from scratch.
The build-cache job:
- Runs as a matrix for both python311 and python313
- Builds the Nix development environment
- Saves the cache via cache-nix-action for downstream jobs
gitleaks, ci, and coverage jobs now depend on build-cache to ensure
cache is available before they run.
* ci: include lockfile hash in cache key for proper invalidation
Add flake.lock and uv.lock hash to the cache key so that:
- Cache is saved when dependencies change (new hash = new key)
- Old cache is still restored via restore-prefixes-first-match
- Incremental updates build on previous cache
This ensures cache hits do not prevent saving updated derivations
while still benefiting from partial cache restoration.
* ci: remove build-cache job as lockfile hash handles invalidation
Now that cache keys include lockfile hashes, proper invalidation
happens automatically. Each job can build and save its own cache,
making the dedicated build-cache job unnecessary.
* ci: add pyproject.toml and src to cache key hash
Include pyproject.toml and src/**/*.py in the cache key hash
since source changes affect the editable install derivation.1 parent daa1a7e commit ee67062
File tree
5 files changed
+268
-84
lines changed- .github
- actions/setup-nix
- workflows
5 files changed
+268
-84
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
3 | 8 | | |
4 | 9 | | |
5 | 10 | | |
| |||
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 37 | + | |
43 | 38 | | |
44 | 39 | | |
45 | 40 | | |
| |||
48 | 43 | | |
49 | 44 | | |
50 | 45 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 46 | + | |
| 47 | + | |
54 | 48 | | |
55 | 49 | | |
56 | | - | |
| 50 | + | |
57 | 51 | | |
58 | 52 | | |
59 | | - | |
| 53 | + | |
60 | 54 | | |
61 | 55 | | |
62 | | - | |
| 56 | + | |
63 | 57 | | |
64 | 58 | | |
65 | 59 | | |
| |||
73 | 67 | | |
74 | 68 | | |
75 | 69 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | 70 | | |
80 | 71 | | |
81 | 72 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments