Skip to content

[KISSA-46] ci(nix): nix flake check ジョブを追加 + Determinate 競合修正#16

Merged
gotomts merged 3 commits into
feature/nix-migration-epicfrom
feature/nix-migration-s14-ci
May 13, 2026
Merged

[KISSA-46] ci(nix): nix flake check ジョブを追加 + Determinate 競合修正#16
gotomts merged 3 commits into
feature/nix-migration-epicfrom
feature/nix-migration-s14-ci

Conversation

@gotomts
Copy link
Copy Markdown
Owner

@gotomts gotomts commented May 12, 2026

Summary

PR で nix/ が変更されるたびに nix flake checknix build .#m5mbp.system --no-link を走らせる flake-check ジョブ を追加する。並行 Claude セッションを止めずに drift (例: Brewfile 更新時の homebrew.nix 追従漏れ) を継続検知できる。

加えて、CI 試運転で発見した Determinate Nix と nix-darwin の競合nix.enable = false で解消する。

変更内容

  1. nix/hosts/m5mbp/darwin.nix: nix.settings.experimental-features 宣言を削除し、nix.enable = false に置換 (Determinate Nix daemon に管理を委ねる)
  2. .github/workflows/nix-check.yml (新規): flake-check ジョブ
    • nix flake check
    • nix build .#darwinConfigurations.m5mbp.system --no-link

スコープ縮小の経緯

当初は darwin-rebuild switch まで CI で実行する案 (ci host 専用構成) を試したが:

  • 本番 (m5mbp) と CI 環境 (runner / TCC / GUI / hardware) の差分を埋める作業が膨らみ、本番投入の安全性向上に対する費用対効果が悪かった
  • 1 度の試運転で Determinate Nix と nix-darwin の競合 という本番ブロッカーを発見できたことで CI の主目的は達成
  • それ以降の iteration は CI 環境固有の問題 (PATH 設定 / smoke test の書き方 / home-manager profile 配置) に終始した

→ ci host / homebrew-ci.nix / ci-switch ジョブは採用見送り。activation の検証は実機での darwin-rebuild buildswitch で行う方針。

検証

  • nix flake check
  • nix build .#darwinConfigurations.m5mbp.system --no-link

Test plan

  • flake-check ジョブが PR で自動実行されて green になる
  • このブランチ自体が nix-check workflow の動作確認となる
  • 後日、ローカル PC で sudo darwin-rebuild switch --flake .#m5mbpnix.enable = false 修正により完走する (実機検証)

🤖 Generated with Claude Code

@gotomts gotomts added the nix-switch-test Trigger ci-switch job in nix-check.yml workflow label May 12, 2026
@gotomts gotomts changed the title feat(nix): CI 用 host + GitHub Actions workflow を追加 [KISSA-46] feat(nix): CI 用 host + GitHub Actions workflow を追加 May 12, 2026
@gotomts gotomts removed the nix-switch-test Trigger ci-switch job in nix-check.yml workflow label May 12, 2026
gotomts added 2 commits May 13, 2026 11:30
nix-darwin 側で Nix 管理を無効化し、Determinate Nix の daemon に委ねる。
nix-command / flakes は Determinate がデフォルト有効なため、旧来の
`nix.settings.experimental-features` 宣言は削除する。

S14 (CI 検証) の試運転で `darwin-rebuild switch` が以下のエラーで
失敗していたため発見した本番ブロッカー:

  error: Determinate detected, aborting activation
  Determinate uses its own daemon to manage the Nix installation that
  conflicts with nix-darwin's native Nix management.

  To turn off nix-darwin's management of the Nix installation, set:
      nix.enable = false;

ローカル PC にも Determinate Nix が入っているため、本修正なしでは
m5mbp で `darwin-rebuild switch` を実行できない状態だった。CI で
事前検出できた本番投入ブロッカー。
PR で nix/ が変更されるたびに以下を実行する flake-check ジョブを追加:
- nix flake check (構文 / 型 / 依存解決の壊れ検知)
- nix build .#darwinConfigurations.m5mbp.system --no-link (closure 構築)

並行 Claude セッションへの影響なく drift を継続検知できる。Brewfile を
更新したのに homebrew.nix を直し忘れた、といったケースを物理防止する。

スコープ縮小の経緯:
- 当初は ci 専用 host (username=runner) で `darwin-rebuild switch` まで
  CI で走らせる構成を試した
- しかし本番 (m5mbp) と CI 環境 (runner / TCC / GUI / hardware) の差分を
  埋める作業が膨らみ、本番投入の安全性向上に対して費用対効果が悪かった
- 1 度の試運転で Determinate Nix と nix-darwin の競合 (前コミット
  `nix.enable = false`) を発見したことで CI の主目的は達成
- それ以降の iteration は CI 環境固有の問題に終始したため、ci-switch
  ジョブと ci host 定義は採用見送り
- activation の検証は実機での `darwin-rebuild build` → `switch` で行う

設計:
- runs-on: macos-latest (最新 macOS runner に自動追従)
- DeterminateSystems/nix-installer-action でローカルと同じ Determinate Nix
- run: で untrusted input (github.event.*) を一切評価しない (injection 対策)
- concurrency で同一 ref の重複 run をキャンセルし課金を抑制
@gotomts gotomts force-pushed the feature/nix-migration-s14-ci branch from df58d1e to af4fb2c Compare May 13, 2026 02:31
@gotomts gotomts changed the title [KISSA-46] feat(nix): CI 用 host + GitHub Actions workflow を追加 [KISSA-46] ci(nix): nix flake check ジョブを追加 + Determinate 競合修正 May 13, 2026
これまで feature/nix-migration-** への push でも push イベントが起動し、
同 SHA に対して pull_request イベントと二重に nix-check が走っていた。
concurrency group が github.ref ベース (push と pull_request で値が違う)
なので互いに cancel されず、毎回手動で push 重複 run をキャンセルする
運用になっていた。

feature branch は PR 経由で常に pull_request イベントを発火させるため、
push トリガーは main の直接 push (hotfix 等) のみに絞る。
@gotomts gotomts merged commit 8e81117 into feature/nix-migration-epic May 13, 2026
1 check passed
@gotomts gotomts deleted the feature/nix-migration-s14-ci branch May 13, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant