From 618595addb2ba984cad9e38ff3e9fc1adda461fc Mon Sep 17 00:00:00 2001 From: Matthew Bessette Date: Thu, 5 Mar 2026 15:38:23 -0500 Subject: [PATCH] VSCode life --- _hosts/cleo-darwin/darwin.nix | 19 ++++++++++++-- _hosts/cleo-darwin/home.nix | 41 ++++++++++++++++++++++++------ config/biome.json | 22 ++++++++++++++++ config/vscode.settings.json | 47 +++++++++++++++++++++++++++++++++++ flake.nix | 1 + 5 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 config/biome.json create mode 100644 config/vscode.settings.json diff --git a/_hosts/cleo-darwin/darwin.nix b/_hosts/cleo-darwin/darwin.nix index 1905b3d..58fbd40 100644 --- a/_hosts/cleo-darwin/darwin.nix +++ b/_hosts/cleo-darwin/darwin.nix @@ -6,6 +6,14 @@ # 1Password SSH Socket environment.variables.SSH_AUTH_SOCK = "~/Library/Group Containers/2BU8OCWD5C.com.1password/t/agent.sock"; + # Set vim as default editor + environment.variables.EDITOR = "vim"; + environment.variables.VISUAL = "vim"; + environment.variables.GIT_EDITOR = "vim"; + + # Add Homebrew to PATH + environment.systemPath = [ "/opt/homebrew/bin" "/opt/homebrew/sbin" ]; + system.primaryUser = "matthew.bessette"; users.users."matthew.bessette" = { name = "matthew.bessette"; @@ -13,11 +21,19 @@ }; # Homebrew for Casks and specific binaries + # In a nix-darwin setup, Homebrew packages are not actually stored inside the Nix store. + # Instead, nix-darwin acts as a manager that triggers the standard Homebrew installation + # process on your macOS system. homebrew = { enable = true; onActivation.cleanup = "uninstall"; + onActivation.autoUpdate = true; + onActivation.upgrade = true; taps = [ "bufbuild/buf" "jacobjohansen/tap" ]; - brews = [ "jacobjohansen/tap/rds-auth-proxy"]; + brews = [ + "biome" + "jacobjohansen/tap/rds-auth-proxy" + ]; casks = [ "android-commandlinetools" "android-platform-tools" @@ -27,7 +43,6 @@ "signal" "spotify" "yubico-yubikey-manager" - "visual-studio-code" "zoom" ]; }; diff --git a/_hosts/cleo-darwin/home.nix b/_hosts/cleo-darwin/home.nix index ada5803..0e82848 100644 --- a/_hosts/cleo-darwin/home.nix +++ b/_hosts/cleo-darwin/home.nix @@ -23,22 +23,34 @@ buf ]; + xdg.configFile."biome.json".source = ../../config/biome.json; + + # Enable direnv for automatic environment switching + programs.direnv = { + enable = true; + nix-direnv.enable = true; # Better Nix flakes integration with caching + }; + # Managed VS Code Extensions (The "Clean" Way) programs.vscode = { enable = true; profiles.default = { + userSettings = builtins.fromJSON (builtins.readFile ../../config/vscode.settings.json); extensions = with pkgs.vscode-extensions; [ - ms-python.python - ms-python.vscode-pylance - ms-python.debugpy - hashicorp.terraform - esbenp.prettier-vscode + # graphql.vscode-graphql + biomejs.biome + bbenoist.nix dbaeumer.vscode-eslint eamodio.gitlens - redhat.vscode-xml + esbenp.prettier-vscode + graphql.vscode-graphql-syntax + hashicorp.terraform mechatroner.rainbow-csv - bbenoist.nix - # Note: Some niche extensions might need to be installed manually in VS Code + # mermaidchart.vscode-mermaid-chart + ms-python.debugpy + ms-python.python + ms-python.vscode-pylance + redhat.vscode-xml ]; }; }; @@ -58,6 +70,19 @@ initContent = '' export SSH_AUTH_SOCK=~/Library/Group\ Containers/2BU8OCWD5C.com.1password/t/agent.sock + + # Auto-allow direnv for directories with flake.nix + auto_allow_direnv() { + if [[ -f flake.nix ]] && [[ ! -f .envrc ]]; then + echo "use flake" > .envrc + direnv allow + elif [[ -f flake.nix ]] && [[ -f .envrc ]]; then + direnv allow + fi + } + + # Run auto-allow when changing directories + chpwd_functions+=(auto_allow_direnv) ''; shellAliases = { diff --git a/config/biome.json b/config/biome.json new file mode 100644 index 0000000..c2d03e1 --- /dev/null +++ b/config/biome.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.4.5/schema.json", + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "formatWithErrors": false, + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 140, + "attributePosition": "auto" + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "jsxQuoteStyle": "double", + "trailingCommas": "all", + "arrowParentheses": "asNeeded" + } + } +} diff --git a/config/vscode.settings.json b/config/vscode.settings.json new file mode 100644 index 0000000..f1c4749 --- /dev/null +++ b/config/vscode.settings.json @@ -0,0 +1,47 @@ +{ + "$schema": "vscode://schemas/settings/user", + "editor.tabSize": 2, + "editor.unicodeHighlight.ambiguousCharacters": false, + "editor.unicodeHighlight.invisibleCharacters": false, + "editor.formatOnSave": true, + "editor.defaultFormatter": "biomejs.biome", + "debug.javascript.autoAttachFilter": "disabled", + "[json]": { + "editor.defaultFormatter": "biomejs.biome", + "editor.formatOnSave": true + }, + "[jsonc]": { + "editor.defaultFormatter": "biomejs.biome", + "editor.formatOnSave": true + }, + "[javascript]": { + "editor.defaultFormatter": "biomejs.biome", + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + } + }, + "[typescript]": { + "editor.defaultFormatter": "biomejs.biome", + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + } + }, + "js/ts.updateImportsOnPaste.enabled": true, + "js/ts.preferences.importModuleSpecifier": "relative", + "git.openRepositoryInParentFolders": "never", + "github.copilot.nextEditSuggestions.enabled": true, + "chat.tools.terminal.autoApprove": { "yarn test": true, "npm test": true }, + "gitlens.ai.model": "vscode", + "gitlens.ai.vscode.model": "copilot:gpt-4.1", + "chat.viewSessions.orientation": "stacked", + "json.schemaDownload.trustedDomains": { + "https://schemastore.azurewebsites.net/": true, + "https://raw.githubusercontent.com/microsoft/vscode/": true, + "https://raw.githubusercontent.com/devcontainers/spec/": true, + "https://www.schemastore.org/": true, + "https://json.schemastore.org/": true, + "https://json-schema.org/": true, + "https://developer.microsoft.com/json-schemas/": true, + "https://biomejs.dev": true + } +} diff --git a/flake.nix b/flake.nix index 48fb930..1df15dc 100644 --- a/flake.nix +++ b/flake.nix @@ -82,6 +82,7 @@ home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users."matthew.bessette" = import ./_hosts/cleo-darwin/home.nix; + home-manager.backupFileExtension = ".before-nix"; } ]; };