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
9 changes: 8 additions & 1 deletion .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@
"sentry@claude-plugins-official": true,
"postgres-best-practices@supabase-agent-skills": true,
"agent-browser@agent-browser": true,
"context7@intellectronica-skills": true
"context7@intellectronica-skills": true,
"mattpocock-skills@mattpocock": true
},
"extraKnownMarketplaces": {
"claude-plugins-official": {
Expand Down Expand Up @@ -398,6 +399,12 @@
"source": "git",
"url": "https://github.com/supabase/agent-skills.git"
}
},
"mattpocock": {
"source": {
"source": "git",
"url": "https://github.com/mattpocock/skills.git"
}
}
}
}
40 changes: 39 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
- '**.yaml'
- '**.sh'
- '**.bats'
- '**.nix'
- 'nix/**'
- '.github/actions/**'
- '.github/workflows/**'
- '.github/actionlint.yaml'
Expand All @@ -33,6 +35,8 @@ on:
- '**.yaml'
- '**.sh'
- '**.bats'
- '**.nix'
- 'nix/**'
- '.github/actions/**'
- '.github/workflows/**'
- '.github/actionlint.yaml'
Expand Down Expand Up @@ -62,6 +66,7 @@ jobs:
scripts: ${{ steps.filter.outputs.scripts }}
workflows: ${{ steps.filter.outputs.workflows }}
dependencies: ${{ steps.filter.outputs.dependencies }}
nix: ${{ steps.filter.outputs.nix }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

Expand Down Expand Up @@ -92,6 +97,9 @@ jobs:
dependencies:
- 'package.json'
- 'package-lock.json'
nix:
- '**.nix'
- 'nix/**'

lint:
name: Lint & Format
Expand Down Expand Up @@ -258,6 +266,29 @@ jobs:
- name: Check workflow templates match actual workflows
run: npm run workflow:sync:check

nix-eval:
name: Nix Config Eval
runs-on: ubuntu-latest
timeout-minutes: 15
needs: changes
if: needs.changes.outputs.nix == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22

# 評価はプラットフォーム非依存なので Linux ランナーで aarch64-darwin の
# darwinConfigurations を検証できる(ビルドはしない)
- name: Evaluate darwin configurations
working-directory: nix
run: |
for host in keitonoMacBook-Pro oykotnoMacBook-Air; do
echo "Evaluating darwinConfigurations.${host}..."
nix eval --raw ".#darwinConfigurations.\"${host}\".system.drvPath"
echo
done

Comment on lines +269 to +291

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== workflow excerpt =="
sed -n '240,305p' .github/workflows/ci.yml 2>/dev/null || true

echo
echo "== checkout usages in ci.yml =="
rg -n "actions/checkout|persist-credentials|evaluate|nix eval|darwinConfigurations|secrets|GITHUB_TOKEN|token" .github/workflows/ci.yml || true

echo
echo "== changed workflow diff stat =="
git diff --stat .github/workflows/ci.yml || true
git diff -- .github/workflows/ci.yml | sed -n '1,260p' || true

Repository: keito4/config

Length of output: 3622


🌐 Web query:

actions/checkout persist-credentials default true README

💡 Result:

In the actions/checkout GitHub Action, the persist-credentials parameter is a configuration option that determines whether the authentication token or SSH key used to check out the repository is persisted in the local git configuration [1][2][3]. Key details include: - Default Value: The default is true [1][2][3]. - Purpose: When set to true, it enables subsequent steps in your workflow to run authenticated git commands (e.g., git push, git fetch) without needing to manually re-configure authentication [1][3][4]. - Security Implementation: The credentials are removed during the post-job cleanup [1][3][5]. As of version v6.0.0, the action was updated to store these credentials in a separate file under the $RUNNER_TEMP directory rather than directly in the local.git/config file, improving security by reducing potential exposure [6][7]. - Opt-out: You can explicitly set persist-credentials: false in your workflow step if you do not want the credentials to be persisted [1][3][4]. While this setting has been the subject of long-standing security discussions regarding the exposure of tokens to other steps in a job, it remains the default behavior to support common automation workflows [8][9]. Users are generally advised to follow the principle of least privilege by setting appropriate repository permissions for the GITHUB_TOKEN used in their workflows [9].

Citations:


Disable credential persistence for the checkout used by Nix evaluation.

actions/checkout persists the GitHub token by default, and this job then evaluates PR-controlled Nix darwinConfigurations. Add persist-credentials: false to this checkout step.

Proposed fix
       - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+        with:
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
nix-eval:
name: Nix Config Eval
runs-on: ubuntu-latest
timeout-minutes: 15
needs: changes
if: needs.changes.outputs.nix == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
# 評価はプラットフォーム非依存なので Linux ランナーで aarch64-darwin の
# darwinConfigurations を検証できる(ビルドはしない)
- name: Evaluate darwin configurations
working-directory: nix
run: |
for host in keitonoMacBook-Pro oykotnoMacBook-Air; do
echo "Evaluating darwinConfigurations.${host}..."
nix eval --raw ".#darwinConfigurations.\"${host}\".system.drvPath"
echo
done
nix-eval:
name: Nix Config Eval
runs-on: ubuntu-latest
timeout-minutes: 15
needs: changes
if: needs.changes.outputs.nix == 'true'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
# 評価はプラットフォーム非依存なので Linux ランナーで aarch64-darwin の
# darwinConfigurations を検証できる(ビルドはしない)
- name: Evaluate darwin configurations
working-directory: nix
run: |
for host in keitonoMacBook-Pro oykotnoMacBook-Air; do
echo "Evaluating darwinConfigurations.${host}..."
nix eval --raw ".#darwinConfigurations.\"${host}\".system.drvPath"
echo
done
🧰 Tools
🪛 zizmor (1.26.1)

[warning] 276-276: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for 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.

In @.github/workflows/ci.yml around lines 269 - 291, Update the checkout step in
the nix-eval job to set persist-credentials to false, while preserving the
existing pinned actions/checkout reference and all other evaluation steps.

Source: Linters/SAST tools

pr-size-check:
name: PR Size Check
runs-on: ubuntu-latest
Expand All @@ -281,7 +312,7 @@ jobs:
name: Quality Gate
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [changes, lint, test, integration-test, actionlint, workflow-template-sync]
needs: [changes, lint, test, integration-test, actionlint, workflow-template-sync, nix-eval]
if: always()
steps:
- name: Check job results
Expand All @@ -291,6 +322,7 @@ jobs:
INTEGRATION_RESULT: ${{ needs.integration-test.result }}
ACTIONLINT_RESULT: ${{ needs.actionlint.result }}
WORKFLOW_TEMPLATE_SYNC_RESULT: ${{ needs.workflow-template-sync.result }}
NIX_EVAL_RESULT: ${{ needs.nix-eval.result }}
run: |
echo "## Quality Gate Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
Expand All @@ -301,6 +333,7 @@ jobs:
echo "| Integration Tests | $INTEGRATION_RESULT |" >> $GITHUB_STEP_SUMMARY
echo "| Workflow Lint | $ACTIONLINT_RESULT |" >> $GITHUB_STEP_SUMMARY
echo "| Workflow Template Sync | $WORKFLOW_TEMPLATE_SYNC_RESULT |" >> $GITHUB_STEP_SUMMARY
echo "| Nix Config Eval | $NIX_EVAL_RESULT |" >> $GITHUB_STEP_SUMMARY

- name: Verify all checks passed
env:
Expand All @@ -309,6 +342,7 @@ jobs:
INTEGRATION_RESULT: ${{ needs.integration-test.result }}
ACTIONLINT_RESULT: ${{ needs.actionlint.result }}
WORKFLOW_TEMPLATE_SYNC_RESULT: ${{ needs.workflow-template-sync.result }}
NIX_EVAL_RESULT: ${{ needs.nix-eval.result }}
run: |
# skipped は成功扱い(該当ファイルの変更がない場合)
function check_result() {
Expand Down Expand Up @@ -337,6 +371,10 @@ jobs:
echo "::error::Workflow Template Sync failed"
FAILED=true
fi
if ! check_result "$NIX_EVAL_RESULT"; then
echo "::error::Nix Config Eval failed"
FAILED=true
fi

if [ "$FAILED" = true ]; then
echo "::error::Quality gate failed - one or more jobs did not succeed"
Expand Down
3 changes: 3 additions & 0 deletions .zsh/configs/pre/path.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ PATH="/opt/homebrew/bin:$PATH"
# ensure dotfiles bin directory is loaded first
PATH="$HOME/.bin:/usr/local/sbin:$PATH"

# claude / codex などのネイティブインストーラーは ~/.local/bin に入れる
PATH="$HOME/.local/bin:$PATH"

# mkdir .git/safe in the root of repositories you trust
PATH=".git/safe/../../bin:$PATH"

Expand Down
14 changes: 7 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Development infrastructure template repository providing DevContainer images, CI
| `ci-check` | PR作成後にCIの結果を確認し、失敗している場合は修正する。PR作成完了後に自動的にこのスキルを適用してCIの状態を監視し、失敗時は修正を行うこと。 |
| `codex-review` | PR作成後にOpenAI Codexによるコードレビューを実行する。Codex CLIがインストール済みの場合、PR作成完了後に自動的にこのスキルを適用してレビューを実行すること。 |
| `gemini-review` | PR作成後にGoogle Gemini CLIによるコードレビューを実行する。Gemini CLIがインストール済みの場合、PR作成完了後に自動的にこのスキルを適用してレビューを実行すること。 |
| `n8n-workflow-pr-review` | keito4-org/n8n_custom_node の n8n ワークフロー/テンプレートPRをレビューする。ワークフロー同期PR(workflow-sync/\*)の退行判定、資格情報のMAS... |
| `n8n-workflow-pr-review` | keito4-org/n8n_custom_node の n8n ワークフロー/テンプレートPRをレビューする。ワークフロー同期PR(workflow-sync/*)の退行判定、資格情報のMAS... |

## CI/CD Workflows

Expand All @@ -149,12 +149,12 @@ Development infrastructure template repository providing DevContainer images, CI

The following scripts are auto-detected and run before git commit/push:

| Script | Command | Purpose |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | -------------------------- | ----------------------- |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '\*.sh' -type f | xargs -r shellcheck -x` | Shell script validation |
| Script | Command | Purpose |
| ----------------------------------------------------------------------------------------------------------------------- | --------------------------------- | -------------------------- |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '*.sh' -type f | xargs -r shellcheck -x` | Shell script validation |
Comment on lines +152 to +157

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Escape the pipe in the shellcheck command.

The | in Line 157 creates a fourth Markdown table column, so the documented command is rendered incorrectly. Escape it as \| while preserving the corrected *.sh glob.

Proposed fix
-| `shellcheck` | `find script -name '*.sh' -type f | xargs -r shellcheck -x` | Shell script validation |
+| `shellcheck` | `find script -name '*.sh' -type f \| xargs -r shellcheck -x` | Shell script validation |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| Script | Command | Purpose |
| ----------------------------------------------------------------------------------------------------------------------- | --------------------------------- | -------------------------- |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '*.sh' -type f | xargs -r shellcheck -x` | Shell script validation |
| Script | Command | Purpose |
| ----------------------------------------------------------------------------------------------------------------------- | --------------------------------- | -------------------------- |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '*.sh' -type f \| xargs -r shellcheck -x` | Shell script validation |
🧰 Tools
🪛 markdownlint-cli2 (0.23.0)

[warning] 157-157: Table column count
Expected: 3; Actual: 4; Too many cells, extra data will be missing

(MD056, table-column-count)

🤖 Prompt for 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.

In `@AGENTS.md` around lines 152 - 157, Escape the pipe character in the
shellcheck command within the scripts table as \| so Markdown keeps the command
in one column, while preserving the existing *.sh glob and command behavior.

Source: Linters/SAST tools

| Additional test commands: `test:integration` (BATS), `test:coverage` (Jest + coverage), `test:all` (unit + integration) |

## Hooks
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Use the setup guides instead of copying snippets from this README:
- [Mobile: Android](docs/setup/mobile-android.md)
- [Mobile: Flutter](docs/setup/mobile-flutter.md)
- [Windows](docs/setup/windows.md)
- [macOS 新規マシン](docs/setup/macos.md)

## Security

Expand Down
1 change: 1 addition & 0 deletions docs/setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| [mobile-android.md](./mobile-android.md) | モバイル (Android) |
| [desktop-extension-ts.md](./desktop-extension-ts.md) | デスクトップ拡張 (TS) |
| [windows.md](./windows.md) | Windows ネイティブ |
| [macos.md](./macos.md) | macOS 新規マシン |

---

Expand Down
118 changes: 118 additions & 0 deletions docs/setup/macos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# macOS 新規マシンセットアップ

新規 Mac (Apple Silicon) をこのリポジトリの nix-darwin 構成で立ち上げる手順。
実際の新規マシンセットアップ (oykotnoMacBook-Air, 2026-07) で検証済み。

## 前提

- Apple Silicon Mac (`aarch64-darwin`)
- 管理者権限のあるユーザー
- `git` が使えること (初回 `git` 実行時に Xcode Command Line Tools が入る)

## 1. リポジトリの取得

ghq 階層に配置する (zsh エイリアスや private-config 参照がこのパスを前提とする)。

```bash
mkdir -p ~/develop/github.com/keito4
git clone https://github.com/keito4/config.git ~/develop/github.com/keito4/config
```

## 2. Homebrew のインストール

nix-darwin の homebrew モジュールは brew 本体がインストール済みであることを前提とする。

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

サードパーティ tap の信頼設定 (Homebrew 6+) は activation 時に自動で行われる
(`nix/modules/homebrew.nix` の preActivation)。

## 3. Nix のインストール

```bash
curl -fsSL https://install.determinate.systems/nix | sh -s -- install
```

> **Note**: Determinate Nix を使う場合、nix-darwin の Nix 管理と衝突するため
> flake のホスト定義で `determinateNix = true` を指定する (手順 5)。

## 4. GUI 前提の準備

- **App Store にサインイン**する (`masApps` の Xcode / LINE 等のインストールに必要)
- **Kanary を手動インストール**する ([ADR 0016](../adr/0016-use-kanary-for-keyboard-remapping.md))。
<https://kanary.download/download> から ZIP を取得し、`Kanary.app` を
`/Applications` または `~/Applications` に配置する。無いと activation が
システムチェックで失敗する。

## 5. flake にホストを追加

`nix/flake.nix` の `darwinConfigurations` に新規マシンのエントリを追加する。

```nix
"<hostname>" = mkDarwin {
hostname = "<hostname>"; # scutil --get LocalHostName の値
username = "<username>"; # whoami の値
determinateNix = true; # Determinate Nix の場合のみ
};
```

## 6. 初回の darwin-rebuild

初回は darwin-rebuild が未導入のため `nix run` で実行する。

```bash
sudo /nix/var/nix/profiles/default/bin/nix run nix-darwin/master#darwin-rebuild \
--extra-experimental-features "nix-command flakes" \
-- switch --flake ~/develop/github.com/keito4/config/nix
```

初回は Cask 群のインストールで時間がかかる。2 回目以降は `make nix-switch`
(または zsh エイリアス `nix-switch`) で適用できる。

## 7. Claude Code / エージェント設定

```bash
# Claude Code CLI (ネイティブインストーラー、~/.local/bin に配置)
curl -fsSL https://claude.ai/install.sh | bash

# private-config (dotfiles の symlink 先)
gh repo clone keito4/private-config ~/develop/github.com/keito4/private-config

# 設定同期 + プラグインインストール
cd ~/develop/github.com/keito4/config
make claude-setup
```

`.claude` / `.mcp.json` / codex / cursor / gemini の設定取り込みは
`./script/import.sh` (または `script/lib/config.sh` の `config::import_*`) で行う。

## 8. 個人設定

```bash
# Git の個人情報 (リポジトリ側は意図的に未設定)
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

# 1Password にサインインした後
make credentials
```

## 9. 権限の許可 (GUI)

初回起動時に macOS の許可が必要:

- **Kanary**: Gatekeeper の確認、アクセシビリティ / 入力監視
- **skhd**: アクセシビリティ (許可しないと IME ショートカットが動かない)
- **Xcode**: 初回起動時のライセンス同意

## トラブルシューティング

| 症状 | 原因 / 対処 |
| -------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `error: Determinate detected, aborting activation` | flake のホスト定義に `determinateNix = true` を指定する |
| `error: Kanary.app is required for keyboard remapping.` | 手順 4 の Kanary をインストールする |
| `Refusing to load formula ... from untrusted tap` | preActivation が自動で `brew trust` する。手動なら `brew trust <tap>` |
| `typeset: -g: invalid option` でスクリプトやテストが失敗 | macOS 標準 bash 3.2 が原因。brew の `bash` (Brewfile 管理) が入っているか確認 |
| `warning: $HOME ... is not owned by you` | sudo 実行時の無害な警告 |
60 changes: 40 additions & 20 deletions nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,49 @@
}:
let
system = "aarch64-darwin";
username = "keito";
hostname = "keitonoMacBook-Pro";
configRoot = ../.;
in
{
darwinConfigurations.${hostname} = nix-darwin.lib.darwinSystem {
inherit system;
modules = [
./hosts/darwin

home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "before-home-manager";
extraSpecialArgs = {
inherit configRoot;
mkDarwin =
{
hostname,
username,
# Determinate Nix はデーモンを自前管理するため nix-darwin の Nix 管理と衝突する
determinateNix ? false,
}:
nix-darwin.lib.darwinSystem {
inherit system;
specialArgs = {
inherit username determinateNix;
};
modules = [
./hosts/darwin

home-manager.darwinModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "before-home-manager";
extraSpecialArgs = {
inherit configRoot username;
};
users.${username} = import ./home;
};
users.${username} = import ./home;
};
}
];
}
];
};
in
{
darwinConfigurations = {
"keitonoMacBook-Pro" = mkDarwin {
hostname = "keitonoMacBook-Pro";
username = "keito";
};
"oykotnoMacBook-Air" = mkDarwin {
hostname = "oykotnoMacBook-Air";
username = "oykot";
determinateNix = true;
Comment on lines +65 to +68

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add an ADR for the new Darwin host model

This adds a second Darwin configuration with a Determinate Nix mode, which is a non-trivial architecture change to the macOS environment. I searched docs/adr and found no ADR covering the multi-host/Determinate decision, so future agents and reviewers will not have the context the repository requires before implementation; please add an ADR with the context, decision, and consequences.

Useful? React with 👍 / 👎.

};
};

# nix fmt
Expand Down
11 changes: 8 additions & 3 deletions nix/home/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ pkgs, lib, ... }:
{
pkgs,
lib,
username,
...
}:

{
imports = [
Expand All @@ -14,8 +19,8 @@

home = {
stateVersion = "24.11";
username = "keito";
homeDirectory = lib.mkForce "/Users/keito";
inherit username;
homeDirectory = lib.mkForce "/Users/${username}";
};

# Let home-manager manage itself
Expand Down
Loading
Loading