[codex] macOS 設定の汎用化と Homebrew 置換#5
Draft
6uclz1 wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
macOS 向けの Nix 設定を、端末固有の
MacBook-Air-M4前提から、汎用的なmacos設定名で扱える形に整理しました。あわせて、これまで別経路で残っていた Legacy Windows の設定を削除し、Homebrew で管理していた CLI や GUI アプリのうち Nix で直接扱えるものを Nix 管理へ寄せています。この変更により、
darwin-rebuildや bootstrap 実行時に使う flake 参照は#macosに統一されます。一方で、実機の hostname はMacBook-Air-M4のまま維持しているため、現在の利用環境を壊さずに内部識別子だけを一般化できます。問題と影響
従来の構成では、macOS 設定の名前が端末固有の
macbook-air-m4/MacBook-Air-M4に強く結び付いていました。そのため、設定の意図が「この 1 台の Mac 専用」なのか「macOS 全般向け」なのかがコード上で曖昧で、今後ホスト定義を増やしたり役割ごとに整理したりする際の足かせになっていました。また、Nix 化を進めた後も Homebrew によるインストール内容が残っており、どのツールを Nix が責任を持って再現するのかが見えにくい状態でした。設定ソースを 1 つに寄せたいというこのリポジトリの方針に対して、運用上の責務が分散していたのが根本的な問題です。
原因
原因は、Nix 化の第一段階で「まず手元の Mac を動かす」ことを優先したため、host 名と flake の設定識別子を分離せずに実装していたことです。その結果、README、bootstrap script、flake outputs がすべて実機名ベースで結合されていました。
あわせて、Homebrew で入っているパッケージを Nix 側へ集約する専用の module がなく、CLI、GUI アプリ、font の配置方針がコードに表現されていませんでした。Legacy Windows についても、現行の対象外でありながらリポジトリ内に残り続けていました。
修正内容
hosts/macos/default.nixを新設し、configName = "macos"と実機 hostname を分離しました。これに合わせて flake のdarwinConfigurations、check 名、bootstrap script、README の手順を#macosに統一しています。さらに、古い識別子やlegacy/windows参照が残っていないことをflake checkの一部として検査する check も追加しました。Homebrew から移す CLI ツールは Home Manager の
home.packagesに集約し、macOS の GUI アプリとフォントは nix-darwin 側の module に分離しました。GUI アプリは/Applications/Nix Appsにエイリアスを張ることで Finder から辿れるようにし、unfree なアプリを扱うための設定も加えています。Nix 上でそのまま扱いにくいものや今回の方針に合わない Legacy Windows の設定は残さず削除しています。確認内容
nix flake check "path:$PWD" --extra-experimental-features 'nix-command flakes'を実行し、darwin / home-manager の評価と追加した check が通ることを確認しました。加えて、nix eval --raw "path:$PWD#darwinConfigurations.macos.config.networking.hostName" --extra-experimental-features 'nix-command flakes'で実機 hostname がMacBook-Air-M4のまま維持されていることを確認しています。また、README・script・hosts 配下に旧識別子や
legacy/windows参照が残っていないことも grep で確認済みです。これにより、利用者が参照する導入手順と、実際に評価される設定名が一致した状態になっています。