Skip to content

fix(nix): pin a Nix store CPython for uv in the dev-shell - #684

Merged
c-vigo merged 4 commits into
feature/625-nix-claude-migrationfrom
bugfix/683-nixos-uv-python-devshell
Jun 24, 2026
Merged

c-vigo merged 4 commits into
feature/625-nix-claude-migrationfrom
bugfix/683-nixos-uv-python-devshell

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

On a NixOS host, onboarding via direnv allow + just init failed during the uv sync bootstrap. The flake dev-shell carried no Python on PATH and let the nixpkgs uv fetch a managed CPython matching requires-python. That download is a generic, dynamically-linked ELF a NixOS host cannot execute out of the box (no FHS ld-linux, see https://nix.dev/permalink/stub-ld), so uv sync aborted and just init exited non-zero. FHS hosts were unaffected.

This pins a Nix store CPython for uv in the dev-shell (mkProjectShell), so the venv is built from a store interpreter that runs on NixOS and FHS hosts alike. CI is deliberately left on its managed-download path (see below).

Type of Change

  • fix -- Bug fix

Changes Made

  • flake.nix (mkProjectShell): set UV_PYTHON=${pkgs.python314}/bin/python3.14 and UV_PYTHON_DOWNLOADS=never so the dev-shell never downloads a generic managed CPython. UV_PYTHON_DOWNLOADS_JSON_URL is retained (see CI note).
  • CI is the exception — setup-env is unchanged: the provision-via-flake jobs run outside nix develop on an FHS runner, where a Nix store interpreter cannot load pre-commit's manylinux-wheel C extensions (libstdc++.so.6). So the action keeps forwarding UV_PYTHON_DOWNLOADS_JSON_URL only (not UV_PYTHON), and the runner downloads a managed CPython as before. (An earlier revision forwarded UV_PYTHON and broke the pymarkdown hook with a libstdc++ ImportError; that was reverted.)
  • scripts/init.sh: updated the bootstrap comment to describe the pinned interpreter.
  • docs/NIX.md, CHANGELOG.md: documented the dev-shell-pin / CI-download split.

Changelog Entry

Fixed

  • just init no longer fails on NixOS hosts (uv downloaded a CPython NixOS cannot execute) (#683)
    • The flake dev-shell carried no Python and let the nixpkgs uv fetch a managed CPython — a generic, dynamically-linked ELF a NixOS host cannot execute out of the box (no FHS ld-linux) — so uv sync (just init) aborted on NixOS hosts while FHS hosts were unaffected
    • mkProjectShell now pins a Nix store CPython via UV_PYTHON and sets UV_PYTHON_DOWNLOADS=never, so the dev-shell builds the venv from a store interpreter (patched to the store loader) that runs on both NixOS and FHS hosts instead of a downloaded one
    • CI keeps its managed-download path (UV_PYTHON_DOWNLOADS_JSON_URL) and does not receive UV_PYTHON: the provision-via-flake jobs run outside nix develop on an FHS runner, where a Nix store interpreter cannot load pre-commit's manylinux-wheel C extensions (libstdc++.so.6)
    • Added dev-shell tests asserting UV_PYTHON_DOWNLOADS=never and UV_PYTHON pinned to a runnable Nix store CPython 3.14

Testing

  • Tests pass locally (tests/test_flake_devshell.py + tests/test_flake_checks.py → 7 passed, incl. nix flake check)
  • Manual testing performed: verified on a real NixOS host — just init now completes and materializes the venv from the lockfile
  • Full CI (test-suite=all) green on the PR head branch

Acceptance Criteria

  • just init materializes the venv on a NixOS host (no generic CPython download)
  • Onboarding remains working on FHS hosts (no regression; CI green)
  • No generic dynamically-linked CPython is downloaded by uv sync in the dev-shell
  • TDD compliance (RED test committed first)

Refs: #683

c-vigo added 4 commits June 24, 2026 14:33
The dev-shell set no UV_PYTHON / UV_PYTHON_DOWNLOADS, so uv sync downloads a
generic managed CPython that NixOS hosts cannot execute. Add failing tests
asserting UV_PYTHON_DOWNLOADS=never and UV_PYTHON pinned to a runnable Nix
store CPython 3.14.

Refs: #683
The flake dev-shell carried no Python and let the nixpkgs uv fetch a
managed CPython — a generic, dynamically-linked ELF a NixOS host cannot
execute out of the box (no FHS ld-linux) — so `uv sync` (`just init`)
aborted on NixOS hosts while FHS hosts were unaffected. Pin a Nix store
CPython via UV_PYTHON and set UV_PYTHON_DOWNLOADS=never in mkProjectShell,
mirroring the image path, so the venv is built from a store interpreter
patched to the store loader that runs on both NixOS and FHS hosts. The
setup-env flake-provision step forwards UV_PYTHON and UV_PYTHON_DOWNLOADS
in place of the retired UV_PYTHON_DOWNLOADS_JSON_URL.

Refs: #683
Add a Fixed entry for the NixOS `just init` failure and reconcile the
#632 dev-shell bullet plus the docs/NIX.md uv section to the end-state
(UV_PYTHON pin + UV_PYTHON_DOWNLOADS=never), replacing the retired
UV_PYTHON_DOWNLOADS_JSON_URL mechanism.

Refs: #683
…loading

Forwarding UV_PYTHON into CI broke the project-checks lane: provision-via-flake
jobs run outside `nix develop` on an FHS runner, where the Nix store
interpreter cannot load pre-commit's manylinux-wheel C extensions
(libstdc++.so.6), so the pymarkdown hook failed with an ImportError.

Keep the dev-shell pin (UV_PYTHON + UV_PYTHON_DOWNLOADS=never) that fixes NixOS
`uv sync`, but restore UV_PYTHON_DOWNLOADS_JSON_URL in the dev-shell and revert
the setup-env action to forward that URL only (not UV_PYTHON), so the FHS CI
runner downloads a managed CPython for pre-commit as before.

Refs: #683
@c-vigo
c-vigo merged commit 5fd6c5a into feature/625-nix-claude-migration Jun 24, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/683-nixos-uv-python-devshell branch June 24, 2026 13:20
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.

1 participant