Add impure flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming)#3442
Add impure flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming)#3442goodboy wants to merge 2 commits into
flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming)#3442Conversation
- Based on `pyproject.nix`'s impure template, overlays a
major-version-pinned `cpython` (`python313`) so nix(os)
devs can drop into a `nix develop` shell w/ `uv` mgring
the py env.
- Pkgs installed in the dev-shell:
- `bashInteractive` + `bash-completion` to ensure sh
completions activate.
- `uv` for py-deps/venv mgmt, `setuptools` for build.
- `tox` for the test matrix (not declared in any
`-requirements.txt`).
- `ruff` + `pyright` from nixpkgs to avoid sys-sh
integration issues on nix(os).
- `shellHook` sets `UV_PROJECT_ENVIRONMENT=py313` so the
venv lands in `./py313/` instead of the version-ambig
`.venv` default, then `uv add`s the test-requirements
and `tox` group, and `uv lock`s.
Other, TODOs left in-file as ctx for follow-up:
- translate `[docs|test]-requirements.txt` deps into
nixpkgs equivs (prolly via `pyproject.nix`/`uv2nix`).
- decide if core-devs prefer plain `pip install -e .`
over `uv` to avoid the extra tooling layer.
- tip for `xonsh` users: `nix develop -c uv run xonsh`.
(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
flake.nix dev-shell using uv (possibly a proper pk overlay coming)flake.nix dev-shell using uv (possibly a proper pkg overlay coming)
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3442 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19419 19419
Branches 1317 1317
===============================================
Hits 19419 19419 🚀 New features to boost your workflow:
|
flake.nix dev-shell using uv (possibly a proper pkg overlay coming)flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming)
| # ?TODO, if we want to pull `xxx-requirements.txt` from | ||
| # nixpkgs directly? |
There was a problem hiding this comment.
It sounds like we can do something with pyproject-nix.lib.project.loadRequirementsTxt { requirements = builtins.readFile ./test-requirements.txt ; }; based on the docs for https://pyproject-nix.github.io/pyproject.nix/use-cases/requirements.html. Though maybe that's impossible...
| # `test-requirements.[in|txt]` already is super set of | ||
| # `docs-requirements.[in|txt]`? |
There was a problem hiding this comment.
It shouldn't be; actually this is in general an issue because they may be out of sync. This isn't true right now, but I remember at some point Sphinx was pinned to a different version between them.
|
|
||
| # NOTE, a `tox.ini` is included in repo even though no | ||
| # explicit dependency is declared elsewhere. | ||
| uv add --group test tox |
There was a problem hiding this comment.
Huh I thought it was somewhere. We should probably add it to some requirements file because it should be pinned...
| uv add --group test tox | ||
|
|
||
| # generate a `uv.lock` | ||
| uv lock |
There was a problem hiding this comment.
Huh, why's this necessary if you're not using uv2nix in this?
Based on
pyproject.nix's impuretemplate, this overlays a major-version-pinned
cpython(currentlypython313) sonix(OS)devs can drop intoa
nix developshell withuv(via apip-migration)managing the python virtual-env.
More thorough description coming once i refine this a bit more!
Basic usage (will be incrementally updated)
to open a dev-shell for hacking on
triocore on a nixos system,then you will be in a (default
bash) shell and can interact withthe python venv using,
Still TODO
first (commit) draft is very WIP but by non-draft form we should
at least have,
link to relevant docs,
nix-related extension libs/projects (pyproject.toml,uv2nix)flake.nix(is common) to have in repo.uvpkging and import docs (and related alt options to movecloser to
uv-styledpyproject.toml).how much further
uvintegration do we want?requirements.[in|txt]files can be takenfurther per,
https://docs.astral.sh/uv/guides/migration/pip-to-project/#importing-requirements-files
https://docs.astral.sh/uv/guides/migration/pip-to-project/#importing-development-dependency-files
get (AI to help) on refining this to include a proper nixpkgs
overlayoutput.write proper usage docs for
nix(OS)users.README?