From 8f4b178e6bdf960a44e512bf573ba68b727c5ac1 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Tue, 2 Dec 2025 23:02:30 +0100 Subject: [PATCH] add cursor module --- hosts/darwin/home-default.nix | 77 ++++++++++++++++++----------------- modules/cursor.nix | 59 +++++++++++++++++++++++++++ modules/homebrew.nix | 2 +- 3 files changed, 99 insertions(+), 39 deletions(-) create mode 100644 modules/cursor.nix diff --git a/hosts/darwin/home-default.nix b/hosts/darwin/home-default.nix index 2f4fb2b..f821f2e 100644 --- a/hosts/darwin/home-default.nix +++ b/hosts/darwin/home-default.nix @@ -21,6 +21,7 @@ ../../modules/tex.nix ../../modules/fonts.nix ../../modules/linearmouse.nix + ../../modules/cursor.nix ]; nixpkgs.config.allowUnfree = true; @@ -234,44 +235,44 @@ # Uses duti to set default applications for file types via Launch Services home.activation.setFileAssociations = config.lib.dag.entryAfter ["writeBoundary"] '' # Text and code files - open with TextMate - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .txt all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .md all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .markdown all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .nix all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .sh all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .bash all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .zsh all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .fish all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .py all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .js all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .ts all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .jsx all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .tsx all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .json all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .yaml all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .yml all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .toml all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .xml all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .css all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .log all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .csv all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .conf all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .config all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .ini all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .env all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .c all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .cpp all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .h all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .hpp all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .rs all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .go all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .java all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .rb all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .php all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .lua all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .vim all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .tex all - run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .bib all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .txt all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .md all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .markdown all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .nix all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .sh all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .bash all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .zsh all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .fish all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .py all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .js all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .ts all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .jsx all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .tsx all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .json all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .yaml all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .yml all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .toml all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .xml all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .css all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .log all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .csv all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .conf all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .config all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .ini all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .env all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .c all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .cpp all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .h all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .hpp all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .rs all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .go all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .java all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .rb all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .php all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .lua all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .vim all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .tex all + run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .bib all # Documents - PDF with Preview run ${pkgs.duti}/bin/duti -s com.apple.Preview .pdf all diff --git a/modules/cursor.nix b/modules/cursor.nix new file mode 100644 index 0000000..66a914b --- /dev/null +++ b/modules/cursor.nix @@ -0,0 +1,59 @@ +{ config, pkgs, lib, ... }: + +let + configDir = if pkgs.stdenv.isDarwin + then "Library/Application Support/Cursor/User" + else ".config/Cursor/User"; + + cursorCmd = if pkgs.stdenv.isDarwin + then "/opt/homebrew/bin/cursor" + else "cursor"; + + ideSettings = { + "editor.fontFamily" = "'JetBrainsMono Nerd Font Mono', 'Noto Sans CJK SC', 'Noto Sans CJK TC', monospace"; + "editor.fontSize" = 14; + "editor.tabSize" = 2; + "editor.insertSpaces" = true; + "editor.wordWrap" = "off"; + "editor.lineNumbers" = "on"; + "editor.autoIndent" = "advanced"; + + "workbench.colorTheme" = "Gruvbox Dark Hard"; + + "vim.leader" = ""; + "vim.useSystemClipboard" = true; + "vim.normalModeKeyBindingsNonRecursive" = [ + { before = ["" "w"]; commands = ["workbench.action.files.save"]; } + { before = ["" "q"]; commands = ["workbench.action.closeActiveEditor"]; } + { before = ["" "e"]; commands = ["workbench.action.toggleSidebarVisibility"]; } + { before = [""]; commands = ["workbench.action.previousEditor"]; } + { before = [""]; commands = ["workbench.action.nextEditor"]; } + { before = ["" "x"]; commands = ["workbench.action.closeActiveEditor"]; } + { before = ["" "X"]; commands = ["workbench.action.closeOtherEditors"]; } + { before = ["" "t"]; commands = ["workbench.action.quickOpen"]; } + { before = ["" "g"]; commands = ["workbench.action.findInFiles"]; } + ]; + }; + + cliConfig = {}; + +in +{ + config = { + home.file."${configDir}/settings.json" = { + text = builtins.toJSON ideSettings; + }; + + home.file.".cursor/cli-config.json" = { + text = builtins.toJSON cliConfig; + }; + + home.activation.installCursorExtensions = config.lib.dag.entryAfter ["writeBoundary"] '' + if command -v ${cursorCmd} &> /dev/null; then + run ${cursorCmd} --install-extension vscodevim.vim 2>/dev/null || true + run ${cursorCmd} --install-extension jdinhlife.gruvbox 2>/dev/null || true + run ${cursorCmd} --install-extension jnoortheen.nix-ide 2>/dev/null || true + fi + ''; + }; +} diff --git a/modules/homebrew.nix b/modules/homebrew.nix index 695cdd0..67a27fe 100644 --- a/modules/homebrew.nix +++ b/modules/homebrew.nix @@ -14,6 +14,7 @@ ]; casks = [ # GUI applications - manually installed apps now managed by Homebrew + "cursor" "keepassxc" "keycastr" "inkscape" @@ -22,7 +23,6 @@ "obsidian" "snipaste" "ghostty" - "textmate" "slidepilot" "tencent-meeting" "ovito"