Rebuild stale `uv` envs after flake updates

`uv sync` accepts an existing same-minor Python even when its Nix
store path belongs to an older closure. That can leave a glibc 2.40
interpreter loading Qt built against glibc 2.42.

- derive the Python package once from `cpython`
- clear `py313` when its interpreter target differs from the flake
- ignore inherited `VIRTUAL_ENV` before syncing

(this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
flake_update
Gud Boi 2026-07-21 16:37:59 -04:00
parent 3da8900f68
commit ceb806c136
1 changed files with 17 additions and 1 deletions

View File

@ -29,6 +29,7 @@
# XXX NOTE XXX, for now we overlay specific pkgs via
# a major-version-pinned-`cpython`
cpython = "python313";
python = pkgs.${cpython};
pypkgs = pkgs."${cpython}Packages";
in
{
@ -47,7 +48,7 @@
qt6.qtbase
uv
python313 # ?TODO^ how to set from `cpython` above?
python
pypkgs.pyqt6
pypkgs.pyqt6-sip
pypkgs.qtpy
@ -88,8 +89,23 @@
export QT_WAYLAND_SHELL_INTEGRATION="xdg-shell"
# ------ uv ------
# ignore any venv inherited from an outer checkout
unset VIRTUAL_ENV
# - always use the ./py313/ venv-subdir
export UV_PROJECT_ENVIRONMENT="py313"
# Rebuild after a flake update changes the Nix Python closure.
venv_python="$UV_PROJECT_ENVIRONMENT/bin/python"
nix_python="$(readlink -f "${python}/bin/python3")"
if test -e "$venv_python" \
&& test "$(readlink -f "$venv_python")" != "$nix_python"
then
uv venv \
--clear \
--python "$nix_python" \
"$UV_PROJECT_ENVIRONMENT"
fi
# sync project-env with all extras
uv sync --dev --all-extras --no-group lint
source "$UV_PROJECT_ENVIRONMENT/bin/activate"