Commit 7c412e20d835

Vincent Demeester <vincent@sbr.pm>
2026-03-30 15:22:36
fix(zsh): detect nix store path changes in tool caches
Timestamp check alone misses nix updates where the store path changes but symlink mtime doesn't. Now also verifies the resolved binary path is present in the cached output.
1 parent 6c4692e
Changed files (2)
dots
config
dots/config/zsh/tools/direnv.zsh
@@ -2,9 +2,11 @@
 has direnv || return
 
 local cache=${XDG_CACHE_HOME:-$HOME/.cache}/zsh/direnv-init.zsh
-local bin=${commands[direnv]}
+local bin=$(realpath ${commands[direnv]})
 
-if [[ ! -f $cache || $bin -nt $cache ]]; then
+# Regenerate if cache is missing, binary is newer, or the resolved
+# path changed (e.g. nix store path updated without timestamp change)
+if [[ ! -f $cache || $bin -nt $cache ]] || ! grep -qF "$bin" "$cache" 2>/dev/null; then
   mkdir -p ${cache:h}
   direnv hook zsh > "$cache"
   _zsh_compile_if_needed "$cache"
dots/config/zsh/tools/fzf.zsh
@@ -3,9 +3,11 @@ has fzf || return
 [[ $options[zle] = on ]] || return
 
 local cache=${XDG_CACHE_HOME:-$HOME/.cache}/zsh/fzf-init.zsh
-local bin=${commands[fzf]}
+local bin=$(realpath ${commands[fzf]})
 
-if [[ ! -f $cache || $bin -nt $cache ]]; then
+# Regenerate if cache is missing, binary is newer, or the resolved
+# path changed (e.g. nix store path updated without timestamp change)
+if [[ ! -f $cache || $bin -nt $cache ]] || ! grep -qF "$bin" "$cache" 2>/dev/null; then
   mkdir -p ${cache:h}
   fzf --zsh > "$cache"
   _zsh_compile_if_needed "$cache"