mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
oh-my-posh: add cache clearing on package version changes (#7757)
* add cache clearing for oh-my-posh package changes Using oh-my-posh creates script files in `~/.cache/oh-my-posh` which include an old derivation path. Once that path is garbage collected, oh-my-posh stops working preventing to successfully create new shells. ``` bash: /nix/store/5ddhz8nsahf1d03smzx2xpmynjspjfh8-oh-my-posh-26.8.0/bin/oh-my-posh: No such file or directory ``` * fix oh-my-posh package reference in cache clear Use the configured value from programs.oh-my-posh.package as the value of oh-my-posh to compare during cache cleanup.
This commit is contained in:
@@ -94,5 +94,21 @@ in
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
# Clear oh-my-posh cache when the oh-my-posh package derivation changes
|
||||
home.activation.ohMyPoshClearCache = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
set -eu
|
||||
nixver="${config.programs.oh-my-posh.package}"
|
||||
cache="${config.xdg.cacheHome}/oh-my-posh"
|
||||
state="$cache/pkg-path"
|
||||
|
||||
if [ ! -f "$state" ] || [ "$(cat "$state")" != "$nixver" ]; then
|
||||
rm -rf "$cache"
|
||||
fi
|
||||
|
||||
mkdir -p "$cache"
|
||||
printf '%s' "$nixver" > "$state"
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user