From 0c7c71a2128000a8596495ec0b8841cf7407bb60 Mon Sep 17 00:00:00 2001 From: Evgeny Zislis Date: Wed, 10 Sep 2025 05:15:16 +0300 Subject: [PATCH] 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. --- modules/programs/oh-my-posh.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/programs/oh-my-posh.nix b/modules/programs/oh-my-posh.nix index 21b02625..087696df 100644 --- a/modules/programs/oh-my-posh.nix +++ b/modules/programs/oh-my-posh.nix @@ -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" + ''; + }; }