Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/nix-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Nix flake / nix-darwin 構成の CI 検証
#
# 目的:
# PR で nix/ が変更されるたびに `nix flake check` と m5mbp の system closure
# ビルドを走らせ、構文・型・依存解決の壊れを検知する。これにより main 更新
# による drift (Brewfile ↔ homebrew.nix 等) を継続検知できる。
#
# 設計判断:
# - `darwin-rebuild switch` 自体は CI で実行しない:
# ci 用に専用 host (username=runner 等) を作って switch する案を試したが、
# 本番 (m5mbp) と CI 環境 (runner / TCC / GUI / hardware) の差分を埋める
# 作業が膨らみ、本番投入の安全性向上に対して費用対効果が悪かった。
# activation の検証は実機での `darwin-rebuild build` → `switch` で行う方針。
# - runs-on: macos-latest を採用 (最新 macOS runner に自動追従)
# - DeterminateSystems/nix-installer-action: ローカル開発と同じ Determinate Nix
#
# セキュリティ:
# - run: で github.event.* の自由文 (PR title / body / commit message 等) を
# 一切評価しない (injection 対策)
name: nix-check

on:
pull_request:
paths:
- 'nix/**'
- '.github/workflows/nix-check.yml'
push:
# feature branch への push は pull_request イベントだけで検証する
# (push と pull_request の重複起動を避ける)。main の直接 push (hotfix 等)
# のみここで拾う。
branches:
- main
paths:
- 'nix/**'
- '.github/workflows/nix-check.yml'

# 同一ブランチで複数 push があった場合、進行中のジョブをキャンセルして最新だけ走らせる
concurrency:
group: nix-check-${{ github.ref }}
cancel-in-progress: true

jobs:
flake-check:
name: nix flake check + build closure
runs-on: macos-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Nix (Determinate Systems)
uses: DeterminateSystems/nix-installer-action@main
with:
# diagnostic 送信を無効化 (Determinate 公式推奨の opt-out)
diagnostic-endpoint: ''

- name: nix flake check
working-directory: nix
run: nix flake check --print-build-logs

- name: Build m5mbp system closure
working-directory: nix
run: |
nix build .#darwinConfigurations.m5mbp.system \
--no-link --print-build-logs
15 changes: 11 additions & 4 deletions nix/hosts/m5mbp/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@
# ユーザースコープオプションは system.primaryUser で対象を明示する必要がある。
system.primaryUser = username;

nix.settings.experimental-features = [
"nix-command"
"flakes"
];
# Determinate Nix (公式インストーラの最新版) と nix-darwin の native Nix 管理は
# 同時稼働できないため、nix-darwin 側の管理を無効化する。
# Determinate Nix は nix-command / flakes をデフォルトで有効化済みなので、
# 旧来の `nix.settings.experimental-features` 宣言は不要。
#
# 本修正は CI 検証 (S14) で `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.
nix.enable = false;

# ユーザー宣言(home-manager から参照される)
users.users.${username} = {
Expand Down
Loading