feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021) - #500

Merged
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell
Jul 15, 2026
Merged

feat: backend Python 環境の Nix フルマネージド化 Phase 1+2(devshell の uv2nix 化と CI 経路一致 / ADR-0021)#500
yusuke0610 merged 4 commits into
mainfrom
feat/adr-0021-phase1-nix-devshell

Conversation

@yusuke0610

@yusuke0610yusuke0610 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 1 と Phase 2 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

経緯: Phase 1 は PR #499 で実装済みでしたが、コミットがマージ(13:27)の 17 分後に push されたため main に取り込まれていませんでした。本 PR はそのコミットを最新 main へ cherry-pick し(+ 下記バグ修正を amend)、Phase 2 を追加したものです。

Phase 1(e420308: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

Phase 2(a65af14: CI のビルド経路を dev と一致させる(uv 単体 → Nix devshell)。

  • test-backend / codegen-drift(test.yml)と mutation-backend(mutation.yml)から setup-uv / uv python install / WeasyPrint apt install / uv sync --locked を撤去し、cachix/install-nix-action + nix-community/cache-nix-action(いずれも SHA ピン)で devshell 経由に置換
  • lint / typecheck / test / codegen はローカルと同一の make ターゲットを呼ぶ(コマンドの SSoT を Makefile に一本化)
  • lock drift 検知は uv lock --check ステップとして保持
  • pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
  • codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)— 旧 .venv を撤去した状態の devshell で ruff / pyright 0 errors / pytest 724 passed / vitest 382 passed / build-web pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(make codegen-types は実行し drift なしを確認済み)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし。開発フロー変更のみ: ローカルは .venv 不要、CI は Nix 経由)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 1+2 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 3 完了後、その際に ADR-0017 / 0014 の記述追従も実施)

レビュー時の注目点

  • 初回 CI は Nix store キャッシュが無いため遅い(devshell 構築数分。timeout は 10→20 分に拡大済み)。2 回目以降は cache-nix-action の restore で短縮される想定
  • pip-audit / codegen(Node 22 化)/ uv lock --check はローカルの devshell で実走確認済み
  • actionlint は追加分クリーン(test.yml:315 の SC2034 は既存警告)
  • smoke-backend は旧経路(pip / Dockerfile)のまま(Phase 3 で Nix 化予定)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改善
    • バックエンドの開発・テスト・Lint・型チェック・移行などを Nix devshell 経由で統一する手順に更新しました。
    • ローカル実行時の環境差分や依存/ネイティブ解決の問題を軽減します。
    • VS Code の Python 設定を簡素化しました。
  • CI
    • バックエンド検証とコード生成ドリフト/ミューテーションテストを Nix devshell ベースに移行しました。
    • Nix ストアキャッシュに対応し、実行効率を改善しました。
  • ドキュメント
    • 実行コマンド例(ruff/pytest/ alembic/ mutmut など)と運用ルールを更新しました。

claudeand others added 2 commits July 15, 2026 23:09
…ase 1)
flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入し、
backend の Python 依存(uv.lock 準拠)を Nix build の virtualenv
(devforge-backend-env)として devshell に提供する。ローカルの backend/.venv を
廃止し、ADR-0021 の発端である VS Code の .venv 絶対パス直書きを解消する。
- flake.nix: uv2nix で uv.lock から pythonSet を構成(wheel 優先)。devshell の
python / pytest / ruff / alembic / uvicorn は Nix build 環境から PATH 解決
- flake.lock: 新規 3 input を追加(transitive は全て follows で既存 nixpkgs に集約)
- Makefile: .venv/bin/* 参照 10 箇所を PATH 解決へ置換。migrate / migrate-create の
nix wrap 漏れも修正。install-backend は devshell ビルド確認のみに変更
- pyright: pyproject / pyrightconfig.json の venv=".venv" 参照を撤廃し、実行側が
--pythonpath で明示する方式へ(ローカル = devshell python3、CI = uv sync の .venv)
- .vscode/settings.json: python.defaultInterpreterPath の絶対パス直書きを撤廃し
direnv(use flake)経由の PATH 解決へ(本 ADR の発端の解消)
- docs / rules / skills: .venv/bin/* 前提のコマンド記載を一括更新
CI(test.yml / mutation.yml)の uv sync 経路は Phase 2 で Nix 化予定のため維持。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
test-backend / codegen-drift / mutation-backend から uv 単体経路
(setup-uv + uv sync --locked + WeasyPrint apt install)を撤去し、
dev と同じ Nix devshell(uv2nix build / flake.nix)経由に置き換える。
- cachix/install-nix-action + nix-community/cache-nix-action を SHA ピンで
導入し、Nix store を flake / uv.lock のハッシュキーでキャッシュする
- lint / typecheck / test / codegen はローカルと同一の make ターゲットを
呼ぶ(コマンドの SSoT を Makefile に一本化)
- uv sync --locked が担っていた lock drift 検知は uv lock --check として保持
- pip-audit は --no-deps --disable-pip へ変更(export 済み完全固定リストの
照合。Nix の python は ensurepip を持たず一時 venv 作成が SIGABRT するため)
- codegen-drift の Node は devshell の nodejs_22 に統一(ローカルと一致)
- timeout 10→20 分(Nix キャッシュミス時の devshell 構築を考慮)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actionsgithub-actionsBot added the feature 新機能 label Jul 15, 2026
@coderabbitai

coderabbitaiBot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b10da675-5b35-4131-b2bf-92f28b4dff21

📥 Commits

Reviewing files that changed from the base of the PR and between 6d25015 and 710dadf.

📒 Files selected for processing (1)
  • backend/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/pyproject.toml

📝 Walkthrough

Walkthrough

Backend local development and CI execution are migrated from .venv commands to a uv2nix-based Nix devshell. Make targets, workflows, editor settings, Pyright configuration, and development guidance are updated accordingly.

Changes

Nix devshell migration

Layer / File(s)Summary
Build the backend environment
flake.nix, backend/pyproject.toml, pyrightconfig.json, .vscode/settings.json
The backend environment is built with uv2nix, and Python tooling receives its interpreter from the devshell at execution time.
Route local tooling through the devshell
Makefile, scripts/gen-third-party-licenses.py
Backend tests, mutation testing, linting, typechecking, code generation, licensing, and migrations use the Nix devshell.
Migrate backend CI and code generation
.github/workflows/test.yml, .github/workflows/mutation.yml
CI installs and caches Nix, runs backend checks through Make targets, and performs mutation testing and code generation inside the devshell.
Update development procedures
.claude/..., docs/development.md
Development commands for Python tooling, Alembic, uvicorn, Ruff, pytest, and mutmut now use nix develop.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant GitHubActions
participant NixDevshell
participant Makefile
participant BackendTools
GitHubActions->>NixDevshell: install, cache, and build environment
NixDevshell->>Makefile: execute backend targets
Makefile->>BackendTools: run tests, lint, typecheck, mutation tests, or code generation
Loading

Possibly related PRs

  • yusuke0610/devforge#418: Changes the backend CI and code-generation workflow areas migrated here to Nix devshell execution.
  • yusuke0610/devforge#446: Adds the Pyright hard gate and backend typecheck workflow integrated here through Make targets.
  • yusuke0610/devforge#499: Updates the same backend dependency and lock-check workflow areas migrated here.

Suggested labels:test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately reflects the main change: migrating backend Python to a Nix-managed uv2nix devshell and aligning CI under ADR-0021.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0021-phase1-nix-devshell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 15, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/CLAUDE.md:
- Line 102: Update the dependency-definition row in CLAUDE.md to replace the
copy-pasteable `cd backend && uv lock` command with `nix develop --command bash
-c "cd backend && uv lock"`, or explicitly state that the command must run
inside an already-active Nix devshell.
In `@backend/pyproject.toml`:
- Around line 57-58: Update the Phase 1 dependency comments near the CI guidance
to state that CI uses the Nix devshell interpreter via make typecheck-backend,
and remove references to uv sync, .venv creation, or .venv/bin/python. Apply the
same correction to the additional guidance at the referenced location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac3cdb31-8b00-4ac6-a3a4-3dedc22de2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e4215f and a65af14.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .claude/CLAUDE.md
  • .claude/rules/backend/database.md
  • .claude/rules/backend/python.md
  • .claude/rules/backend/test.md
  • .claude/rules/common/tdd.md
  • .claude/skills/BE_apply/SKILL.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .claude/skills/tdd/SKILL.md
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .vscode/settings.json
  • Makefile
  • backend/pyproject.toml
  • docs/development.md
  • flake.nix
  • pyrightconfig.json
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (1)
  • pyrightconfig.json

Comment thread.claude/CLAUDE.md Outdated
Comment threadbackend/pyproject.toml Outdated
@yusuke0610
yusuke0610 merged commit 973d8f6 into mainJul 15, 2026
23 checks passed
@yusuke0610
yusuke0610 deleted the feat/adr-0021-phase1-nix-devshell branch July 20, 2026 12:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backendバックエンドciCI / ワークフローdocumentationImprovements or additions to documentationfeature新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@yusuke0610@claude