Skip to content

Commit c5f7aa8

Browse files
committed
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.
1 parent 450bdd7 commit c5f7aa8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@
144144
UV_NO_SYNC = "1";
145145
UV_PYTHON = "${python}/bin/python";
146146
UV_PYTHON_DOWNLOADS = "never";
147+
# Set VIRTUAL_ENV for tools like ty that look for site-packages
148+
VIRTUAL_ENV = "${virtualenv}";
147149
};
148150

149151
shellHook = ''

justfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Helper to run Python commands (uses uv run if not in Nix environment)
2+
_run := if env("VIRTUAL_ENV", "") != "" { "" } else { "uv run " }
3+
14
# Install dependencies and pre-commit hooks
25
install *extras:
36
uv sync {{ extras }}
@@ -15,31 +18,31 @@ lint-fix: format
1518

1619
# Run all tests
1720
test:
18-
uv run pytest
21+
{{ _run }}pytest
1922

2023
# Run tests with coverage
2124
coverage:
22-
uv run pytest --cov --cov-report=term --cov-report=json --cov-report=html
25+
{{ _run }}pytest --cov --cov-report=term --cov-report=json --cov-report=html
2326

2427
# Run tool-specific tests
2528
test-tools:
26-
uv run pytest tests
29+
{{ _run }}pytest tests
2730

2831
# Run example tests
2932
test-examples:
30-
uv run pytest examples
33+
{{ _run }}pytest examples
3134

3235
# Run type checking
3336
ty:
34-
uv run ty check stackone_ai
37+
{{ _run }}ty check stackone_ai
3538

3639
# Run gitleaks secret detection
3740
gitleaks:
3841
gitleaks detect --source . --config .gitleaks.toml
3942

4043
# Update version in __init__.py
4144
update-version:
42-
uv run python scripts/update_version.py
45+
{{ _run }}python scripts/update_version.py
4346

4447
# Build package
4548
build:

0 commit comments

Comments
 (0)