fix(sketchybar): own the config dir as one out-of-store symlink - #167
Merged
Conversation
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.
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.
#162 で入れた
-b hm-bakが引き金になって、rebuild 中にリポジトリのconfigs/wm/sketchybar/配下 52 ファイルが store のシンボリックリンクに置き換わる事故が起きた。その恒久対策。何が起きていたか
home.file.".config/sketchybar"がrecursive = trueだったので、home-manager はファイルを1つずつリンクする。その上に手書きのシンボリックリンク4本(helperhelpersitemsplugins→ チェックアウトへ逆向き、ライブ編集用)が乗っていたため、per-file のリンク先がリポジトリの中に解決されていた。バックアップ拡張子が無い間は、home-manager が既存ファイルを見つけて黙って素通りしていたので表面化しなかった。
-b hm-bakを足した瞬間に「退避して上書き」に変わり、リポジトリ自身のファイルを退避して store リンクで置き換えた。データは失っていない。53個の
.hm-bakを git の内容と突き合わせて全一致を確認したうえで復元済み(唯一の差分は #165 で削除済みの aerospace.sh)。直し方
ディレクトリごと
mkOutOfStoreSymlink1本にした。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成功.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が静かなことを確認するのが確実。