✅️2025/2/2 homebrewをnix-darwin経由で入れる
from ✅️2025/1/28 nix-darwinをFlakes経由で入れる
Macの初期設定の大部分がdotfilesで自動化できてきた
あとできていないところの大部分はGUIアプリを入れる部分
nix-darwinでhomebrew caskを扱えるのでそれで入れたい
nix-darwinにhomebrewを扱う設定があるが、homebrew自体を入れる方法が用意されていない
code:error
nix run nix-darwin -- switch --flake .#mrsekut
building the system configuration...
Password:
error: Using the homebrew module requires homebrew installed, aborting activation
Homebrew doesn't seem to be installed. Please install homebrew separately.
You can install homebrew using the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
error: Recipe nix-darwin-apply failed on line 32 with exit code 2
docsでも名言されていた
nix-darwinではhomebrewは入れられない
https://github.com/LnL7/nix-darwin/blob/master/modules/homebrew.nix
code:nix-darwin/modules/homebrew.nix
options.homebrew = {
enable = mkEnableOption ''
{command}nix-darwin to manage installing/updating/upgrading Homebrew taps, formulae,
and casks, as well as Mac App Store apps and Docker containers, using Homebrew Bundle.
Note that enabling this option does not install Homebrew, see the Homebrew
website(https://brew.sh) for installation instructions.
まじかよmrsekut.icon
nix-homebrewというのを見つけたのでこれを使ってみる
ただまあ、Justfileにhomebrewのinstallコマンドを一つ書けば済むのに
わざわざこんな大仰なものを入れる必要があるか微妙だ
darwin-applyする際に、存在チェックして入れたりpath指定すればいいだけ
ひとまず試してみて、少しでも詰まるならjustfileにしようmrsekut.icon
一部理解していないところはあるが入った
https://github.com/mrsekut/dotfiles/commit/525dbb4f2b8cf460e01fffb3871ef981668a97b5
nix-homebrewでhomebrew-coreを入れてみた
githubで検索かけて出てきたこれのリポジトリを参考にした
https://github.com/paolobrasolin/nix/blob/e61b1a14b0b4c2b34c3bba1c7992aa56b6cd3b22/flake.nix
実際にはhomebrewは不要で、Homebrew Caskを使いたい
nix-homebrewのREADMEの例に以下の3つが書いている
code:nix
"homebrew/homebrew-core" = inputs.homebrew-core;
"homebrew/homebrew-cask" = inputs.homebrew-cask;
"homebrew/homebrew-bundle" = inputs.homebrew-bundle;
が、今欲しいのは、caskのみなので、なくても動くなら他2つは不要
一つずつ消したりしながら試す
coreはなくても動いたmrsekut.icon
しかし、Homebrew Bundleは必要らしい
なんで必要なのかわからんが、ないと動かなかった
code:error
fatal: could not create work tree dir '/opt/homebrew/Library/Taps/homebrew/homebrew-bundle': Permission denied
Error: Failure while executing; git clone https://github.com/Homebrew/homebrew-bundle /opt/homebrew/Library/Taps/homebrew/homebrew-bundle --origin=origin --template= --config core.fsmonitor=false exited with 128.
Error: Failure while executing; /nix/store/svc8bj75bki9i4xm75k220mqcb7lljzb-brew tap homebrew/bundle exited with 1.
error: Recipe nix-darwin-apply failed on line 32 with exit code 1
試しにforkを入れてみた
https://github.com/mrsekut/dotfiles/commit/e9b61ef837120bb9144f31dc5a70d7d7e7fc1967
ちゃんと入ったmrsekut.icon*3
嬉しい
コードから読み取るのが難しいが
homebrew.nix内の
nix-homebrewはnix-homebrewのものであり
homebrewはnix-darwinのものである
あとは個別にGUIアプリをcasks経由で入れていけばいいmrsekut.icon
大方移行できた
https://gyazo.com/54dc6292b2fcfd73f1b318f52325e49a
いったん手動で入れたGUIアプリを、「アプリケーション」ディレクトリから消して、darwin経由で入れた
根本の設定ファイル自体は残っているので、どのアプリの再インストール後の設定も大変ではなかった
Chromeも、以前開いていたタブとか全部残っていたし
次
✅️2025/2/3 dotfilesのディレクトリ構造のリファクタ