Skip to content

fix(devenv): take Python 3.12 from devenv-nixpkgs so it comes from the cache - #13

Merged
Eotel merged 3 commits into
mainfrom
Eotel/devenv-cache-python
Oct 26, 2026
Merged

Eotel merged 3 commits into
mainfrom
Eotel/devenv-cache-python

Conversation

@Eotel

@Eotel Eotel commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

devenv の Python を、公開キャッシュにある devenv-nixpkgs の python312 に替えます。新しい作業場で CPython をソースからビルドしなくなります。

 languages.python = {
   enable = true;
-  version = "3.12";            # nixpkgs-python(follows nixpkgs)→ キャッシュに当たらず手元でビルド
+  package = pkgs.python312;    # devenv-nixpkgs の 3.12.12 → cache.nixos.org から取得
 };
  1. devenv.yaml から nixpkgs-python の input と cachix の nixpkgs-python を外しました。
  2. git-hooks を devenv.yaml に明示しました。これまでは lock にだけ暗黙の input として入っていて、devenv 2.4 で lock を作り直すと消え、git-hooks の assertion で失敗するためです。rev は同じ(5eaaedde414f)です。
  3. direnv の読み込み中は、版を表示する banner(Node で動く basedpyright を含む 4 つの道具を起動する)を出さないようにしました。devenv shell では従来どおり出ます。
  4. lock の devenv の module だけを更新しました(devenv update devenv、2026-10-26 の 6af962f)。2026 年初めの module は devenv 2.4 の CLI と合わず、The option `dotenv.resolved' was accessed but has no value defined でシェルの組み立てに失敗し、direnv がホストの Python に落ちていました。
  5. languages.python.venv.enable = true を足しました。devenv の Python module は、uv sync が作る venv をこの設定のときだけ有効にします(src/modules/languages/python/default.nix の initUvScript)。無いと python・pytest・ty が venv の外のものになり、ty の hook が import を解決できません。

原因: nixpkgs-python を follows: nixpkgs にしていたことです。nixpkgs-python の README には「Do not override the nixpkgs input when using this flake. The cached builds are tied to the pinned nixpkgs revision」とあります。

Evidence

  • Before: version = "3.12" で、nixpkgs-python の CPython を手元でビルドする設定だった。
  • After: devenv eval languages.python.package は python3-3.12.12-env を返します。その中の 2j3gnwp0hsbvrirf23w1q344q7gbcy92-python3-3.12.12 は cache.nixos.org にあります(narinfo が 200)。
  • devenv eval git-hooks.installationScript が評価でき、git-hooks の input が読み込まれることを確かめました。
  • devenv.lock で消えたのは nixpkgs-python・flake-compat_2・root の pre-commit-hooks の別名だけです。nixpkgs・git-hooks の rev は変わりません(devenv は上の 4 で更新)。
  • commit 時の pre-commit(nixfmt)は通りました。
  • 2026-10-27 に、main にこの PR を重ねた新しい作業場で direnv を読み込み、python が .devenv/state/venv/bin/python になることを確かめました。手元でビルドしたのは環境の包みだけです。main だけでは git-hooks の assertion で、4 の前は dotenv.resolved で失敗します。

Merge Danger

Door: two-way

Blast Radius: 手元の devenv シェル

pyproject.toml は >=3.12 だけを求めるので、patch 版の違いは影響しません。

devenv-slow-2-b5

…e cache

languages.python.version pulled CPython from nixpkgs-python, and devenv.yaml
made nixpkgs-python follow our nixpkgs. nixpkgs-python's binary cache is built
against its own pinned nixpkgs, so with that override the interpreter missed
the cache and was compiled locally.

Use pkgs.python312 from devenv-nixpkgs instead; its 3.12.12 build is on
cache.nixos.org. pyproject.toml only requires ">=3.12". Drop the
nixpkgs-python input and its cachix entry.

devenv.yaml never declared git-hooks; the old lock carried it as an
implicit input. Re-locking with devenv 2.4 dropped it, which would fail the
git-hooks assertion. Declare it explicitly; the lock keeps the same
git-hooks revision.

Skip the version banner while direnv loads the shell. It started four
tools, including basedpyright on Node, on every load.
@Eotel Eotel self-assigned this Oct 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T11:26:16.933467Z 44837d5 PR opened
🔒 Security Review 🔄 Running since 2026-10-26T11:25:39.799474Z 44837d5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Eotel added 2 commits October 27, 2026 04:00
The lock pinned the devenv modules from early 2026. With the devenv 2.4
CLI the shell failed to build ("The option `dotenv.resolved' was
accessed but has no value defined"), and direnv fell back to the host
Python. Update only the devenv input with `devenv update devenv`;
nixpkgs and git-hooks stay as they are.
devenv's Python module sources the venv that uv sync creates only when
languages.python.venv.enable is set (initUvScript in
src/modules/languages/python/default.nix). Without it, python, pytest
and ty in the shell came from outside the venv, and the ty hook could
not resolve the project's imports.
@Eotel
Eotel merged commit 032d81f into main Oct 26, 2026
1 check passed
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