From 0ed3c164eec65175d7524fa79ea0827b1c4ffcb5 Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 22 May 2026 19:16:41 -0400 Subject: [PATCH 1/2] Add impure `flake.nix` dev-shell using `uv` - 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 | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..1f3f14ae2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,117 @@ +# An "impure" template thx to `pyproject.nix`, +# https://pyproject-nix.github.io/pyproject.nix/templates.html#impure +# https://github.com/pyproject-nix/pyproject.nix/blob/master/templates/impure/flake.nix +{ + description = "An impure dev-shell (overlay) using `uv`"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small"; + }; + + outputs = + { nixpkgs, ... }: + let + inherit (nixpkgs) lib; + forAllSystems = lib.genAttrs lib.systems.flakeExposed; + in + { + devShells = forAllSystems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + # XXX NOTE XXX, for now we overlay specific pkgs via + # a major-version-pinned-`cpython` + cpython = "python313"; + venv_dir = "py313"; + pypkgs = pkgs."${cpython}Packages"; + in + { + default = pkgs.mkShell { + + packages = [ + # XXX, ensure sh completions activate! + pkgs.bashInteractive + pkgs.bash-completion + + # pkgs.xonsh + pkgs.uv + pkgs.${cpython} # ?TODO^ how to set from `cpython` above? + pkgs."${cpython}Packages".setuptools + + # testing-n-tooling + # ?TODO, if we want to pull `xxx-requirements.txt` from + # nixpkgs directly? + # - [ ] extract-n-translate all `[docs|test]-requirements.txt` deps + # into their equiv nxpkgs equivalents. + # + # For ex. we can explicitily add them like the below, + # but ideally we use a translator lib (like + # `pyproject.nix` and/or `uv2nix`). + # + # pkgs."${cpython}Packages".black + # pkgs."${cpython}Packages".coverage + # pkgs."${cpython}Packages".hypothesis + # pkgs."${cpython}Packages".mypy + # pkgs."${cpython}Packages".pytest + # pkgs."${cpython}Packages".towncrier + + # XXX, pkgs not listed in `-requirements.txt` files. + pkgs."${cpython}Packages".tox + + # XXX, on nix(os), use pkgs version to avoid + # build/sys-sh-integration issues + pkgs.ruff + pkgs.pyright + + ]; + + shellHook = '' + # unmask to debug **this** dev-shell-hook + # set -e + + # RUNTIME-SETTINGS + # ------ uv ------ + # - always use and explicit py-version abbreviated + # `${venv_dir}` (like `./py313/`) venv-subdir instead + # the default (and version ambiguous) `.venv` used by + # `uv`. + export UV_PROJECT_ENVIRONMENT=${venv_dir} + + # - sync the `uv` env with all extras, namely the test + # and docs deps as required by the full CI/CD + # pipeline used on Github. + uv add -r test-requirements.in -c test-requirements.txt --group test + + # ?TODO? next line is unneeded since + # `test-requirements.[in|txt]` already is super set of + # `docs-requirements.[in|txt]`? + # uv add -r docs-requirements.in -c docs-requirements.txt --group docs + + # NOTE, a `tox.ini` is included in repo even though no + # explicit dependency is declared elsewhere. + uv add --group test tox + + # generate a `uv.lock` + uv lock + + # ?TODO, this would update to latest deps versions right? + # - [ ] a dev can invoke this explicitly if wanted? + # uv sync + + # ?TODO? if core-devs would prefer not (encouraging us) + # to use `uv` we can instead use `pip` directly, but it + # seems a bit pedantic and less convenient when devving + # on nix(os). + # pip install -e . + + # ------ HOT-TIPS ------ + # - to launch the py-venv installed `xonsh` (like your + # fave collab @goodboy) run the `nix develop` cmd with, + # >> nix develop -c uv run xonsh + ''; + }; + } + ); + }; +} From 5eb9e9ce878b1ce5849ebea3362a3bc5711ef665 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 23:22:50 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 1f3f14ae2..82c5622e1 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ # - [ ] extract-n-translate all `[docs|test]-requirements.txt` deps # into their equiv nxpkgs equivalents. # - # For ex. we can explicitily add them like the below, + # For ex. we can explicitly add them like the below, # but ideally we use a translator lib (like # `pyproject.nix` and/or `uv2nix`). #