From ceb806c1365497242ab025681f41f9c3d37078ab Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 21 Jul 2026 16:37:59 -0400 Subject: [PATCH] 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.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4d5a8ab5..eeb770b9 100644 --- a/flake.nix +++ b/flake.nix @@ -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"