Skip to content

fix(sketchybar): own the config dir as one out-of-store symlink - #167

Merged
gapul merged 1 commit into
mainfrom
sketchybar-out-of-store
Aug 8, 2026
Merged

fix(sketchybar): own the config dir as one out-of-store symlink#167
gapul merged 1 commit into
mainfrom
sketchybar-out-of-store

Conversation

@gapul

@gapul gapul commented Aug 8, 2026

Copy link
Copy Markdown
Owner

#162 で入れた -b hm-bak が引き金になって、rebuild 中にリポジトリの configs/wm/sketchybar/ 配下 52 ファイルが store のシンボリックリンクに置き換わる事故が起きた。その恒久対策。

何が起きていたか

home.file.".config/sketchybar"recursive = true だったので、home-manager はファイルを1つずつリンクする。その上に手書きのシンボリックリンク4本(helper helpers items plugins → チェックアウトへ逆向き、ライブ編集用)が乗っていたため、per-file のリンク先がリポジトリの中に解決されていた。

バックアップ拡張子が無い間は、home-manager が既存ファイルを見つけて黙って素通りしていたので表面化しなかった。-b hm-bak を足した瞬間に「退避して上書き」に変わり、リポジトリ自身のファイルを退避して store リンクで置き換えた。

データは失っていない。53個の .hm-bak を git の内容と突き合わせて全一致を確認したうえで復元済み(唯一の差分は #165 で削除済みの aerospace.sh)。

直し方

ディレクトリごと mkOutOfStoreSymlink 1本にした。nvim / karabiner / neru と同じ形。home-manager はディレクトリを1エントリとして所有するので、中には一切書き込まない。手書きリンクも不要になり、ライブ編集はそのまま効く。

引っかかったのは生成物の colors.sh。theme.nix から生成していて .config/sketchybar/ の中に置かれていたが、そのディレクトリがチェックアウトそのものになる以上、シンボリックリンク越しに書けばリポジトリに落ちてしまう。なので ~/.config/sketchybar-colors.sh に出した。source "$CONFIG_DIR/colors.sh" で読んでいた13ファイルは、そのパスを直接読むように書き換えた。

検証

  • nix build .#homeConfigurations.gapul.activationPackage 成功
  • 生成された world を確認: .config/sketchybar は単一シンボリックリンクで、辿ると /Users/gapul/.dotfiles/configs/wm/sketchybar に着く(nvim と同じ形)。.config/sketchybar-colors.sh が隣に生成されている。中に per-file エントリが1つも無いことも確認
  • just fmt(deadnix / gitleaks / nixfmt / shellcheck)Pass

適用時の注意

いまの実機は応急処置として手書きリンク4本を削除した状態で、~/.config/sketchybar/ の中身は store 経由になっている。この PR を当てるとディレクトリごと1本のリンクに変わる。適用後に sketchybar を再起動して、バーが出ることと /tmp/sketchybar.err が静かなことを確認するのが確実。

recursive = true made home-manager link every file under .config/sketchybar
individually. Four hand-made symlinks (helper/helpers/items/plugins, pointing
back into the checkout for live editing) sat on top, so those per-file links
resolved into the repository itself. It stayed invisible while home-manager had
no backup extension and silently skipped existing files; once one was set,
activation moved the repository's own files aside and replaced 52 of them with
store symlinks.

The directory is now a single mkOutOfStoreSymlink, the same shape as
nvim/karabiner/neru, so home-manager never writes inside it and live editing
works without the hand-made links.

The generated colors.sh moves to ~/.config/sketchybar-colors.sh, outside the
symlinked directory — writing it through the symlink would land it in the
repository. The 13 scripts that sourced "$CONFIG_DIR/colors.sh" now source that
path directly.
@gapul
gapul merged commit 751dda7 into main Aug 8, 2026
3 checks passed
@gapul
gapul deleted the sketchybar-out-of-store branch August 8, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant