Skip to content

Add impure flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming)#3442

Draft
goodboy wants to merge 2 commits into
mainfrom
nix_dev_overlay
Draft

Add impure flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming)#3442
goodboy wants to merge 2 commits into
mainfrom
nix_dev_overlay

Conversation

@goodboy
Copy link
Copy Markdown
Member

@goodboy goodboy commented May 22, 2026

Based on pyproject.nix's impure
template
, this overlays a major-version-pinned
cpython (currently python313) so nix(OS) devs can drop into
a nix develop shell with uv (via a pip-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 trio core on a nixos system,

nix develop [-c <shell you use>]

then you will be in a (default bash) shell and can interact with
the python venv using,

# once inside nix dev-shell
uv sync  # update deps to latest
uv sync --group test  # update all "test"-dependency-group deps
uv run pytest  # run full test suite (requires above line ^)

Still TODO

first (commit) draft is very WIP but by non-draft form we should
at least have,

- 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
@goodboy goodboy changed the title Add impure flake.nix dev-shell using uv (possibly a proper pk overlay coming) Add impure flake.nix dev-shell using uv (possibly a proper pkg overlay coming) May 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (73cc29e) to head (5eb9e9c).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@goodboy goodboy changed the title Add impure flake.nix dev-shell using uv (possibly a proper pkg overlay coming) Add impure flake.nix dev-shell using uv (possibly a proper <nixpkgs> overlay coming) May 22, 2026
Comment thread flake.nix
Comment on lines +43 to +44
# ?TODO, if we want to pull `xxx-requirements.txt` from
# nixpkgs directly?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Comment thread flake.nix
Comment on lines +87 to +88
# `test-requirements.[in|txt]` already is super set of
# `docs-requirements.[in|txt]`?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread flake.nix

# NOTE, a `tox.ini` is included in repo even though no
# explicit dependency is declared elsewhere.
uv add --group test tox
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh I thought it was somewhere. We should probably add it to some requirements file because it should be pinned...

Comment thread flake.nix
uv add --group test tox

# generate a `uv.lock`
uv lock
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, why's this necessary if you're not using uv2nix in this?

@goodboy goodboy self-assigned this May 23, 2026
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