make cursor extension declarative

This commit is contained in:
Yan Lin 2025-12-02 23:47:46 +01:00
parent eb8de3fbeb
commit bd513a60c5

View file

@ -9,6 +9,13 @@ let
then "/opt/homebrew/bin/cursor" then "/opt/homebrew/bin/cursor"
else "cursor"; else "cursor";
extensions = [
"vscodevim.vim"
"jdinhlife.gruvbox"
"jnoortheen.nix-ide"
"tomoki1207.pdf"
];
ideSettings = { ideSettings = {
"editor.fontFamily" = "'JetBrainsMono Nerd Font Mono', 'Noto Sans CJK SC', 'Noto Sans CJK TC', monospace"; "editor.fontFamily" = "'JetBrainsMono Nerd Font Mono', 'Noto Sans CJK SC', 'Noto Sans CJK TC', monospace";
"editor.fontSize" = 14; "editor.fontSize" = 14;
@ -52,10 +59,18 @@ in
home.activation.installCursorExtensions = config.lib.dag.entryAfter ["writeBoundary"] '' home.activation.installCursorExtensions = config.lib.dag.entryAfter ["writeBoundary"] ''
if command -v ${cursorCmd} &> /dev/null; then if command -v ${cursorCmd} &> /dev/null; then
run ${cursorCmd} --install-extension vscodevim.vim &> /dev/null || true desired="${lib.concatStringsSep " " extensions}"
run ${cursorCmd} --install-extension jdinhlife.gruvbox &> /dev/null || true installed=$(${cursorCmd} --list-extensions 2>/dev/null | tr '[:upper:]' '[:lower:]')
run ${cursorCmd} --install-extension jnoortheen.nix-ide &> /dev/null || true
run ${cursorCmd} --install-extension tomoki1207.pdf &> /dev/null || true for ext in $installed; do
if ! echo "$desired" | tr '[:upper:]' '[:lower:]' | grep -qw "$ext"; then
run ${cursorCmd} --uninstall-extension "$ext" &> /dev/null || true
fi
done
for ext in ${lib.concatStringsSep " " extensions}; do
run ${cursorCmd} --install-extension "$ext" &> /dev/null || true
done
fi fi
''; '';
}; };