Last active
September 4, 2025 23:59
-
-
Save kesor/60273e76db3c54c69f6a68c70613561e to your computer and use it in GitHub Desktop.
oh-my-posh module in Home Manager
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
# include https://github.com/NixOS/nixpkgs/pull/439751 | |
# include https://github.com/nix-community/home-manager/pull/7757 | |
{ | |
config, | |
pkgs, | |
lib, | |
... | |
}: | |
let | |
version = "26.20.1"; | |
ompPkg = pkgs.oh-my-posh.overrideAttrs { | |
inherit version; | |
src = pkgs.fetchFromGitHub { | |
owner = "jandedobbeleer"; | |
repo = "oh-my-posh"; | |
tag = "v${version}"; | |
hash = "sha256-7xwPL13lZhS6A5c7PEEYeBi/XVLdgttxUK03+tT+uso="; | |
}; | |
vendorHash = "sha256-wzgPQN3Y0e4CpJzWfNKCoDrUF4oC0Flx4Bhxt5Bx6XY="; | |
ldflags = [ | |
"-s" | |
"-w" | |
"-X github.com/jandedobbeleer/oh-my-posh/src/build.Version=${version}" | |
"-X github.com/jandedobbeleer/oh-my-posh/src/build.Date=1970-01-01T00:00:00Z" | |
]; | |
postPatch = '' | |
# these tests requires internet access | |
rm cli/image/image_test.go config/migrate_glyphs_test.go cli/upgrade/notice_test.go segments/upgrade_test.go | |
''; | |
meta.changelog = "https://github.com/JanDeDobbeleer/oh-my-posh/releases/tag/v${version}"; | |
}; | |
in | |
{ | |
programs.oh-my-posh = { | |
enable = true; | |
package = ompPkg; | |
}; | |
# 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" | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment