-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 新規マシンでも nix-darwin セットアップが通るようにする #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cdb2243
687eb12
7efedf0
7b88e04
a577c60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.23.0)[warning] 157-157: Table column count (MD056, table-column-count) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||||||||||||
| | Additional test commands: `test:integration` (BATS), `test:coverage` (Jest + coverage), `test:all` (unit + integration) | | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ## Hooks | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| 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 実行時の無害な警告 | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This adds a second Darwin configuration with a Determinate Nix mode, which is a non-trivial architecture change to the macOS environment. I searched Useful? React with 👍 / 👎. |
||
| }; | ||
| }; | ||
|
|
||
| # nix fmt | ||
|
|
||
There was a problem hiding this comment.
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:
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:
persist-credentials=trueplease actions/checkout#2312persist-credentialsor change the default tofalseactions/checkout#485Disable credential persistence for the checkout used by Nix evaluation.
actions/checkoutpersists the GitHub token by default, and this job then evaluates PR-controlled NixdarwinConfigurations. Addpersist-credentials: falseto this checkout step.Proposed fix
📝 Committable suggestion
🧰 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
Source: Linters/SAST tools