From 51ef14630e21da684c04d154d6946df31329e931 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Wed, 27 Aug 2025 14:54:38 -0400 Subject: [PATCH] Claude Code home-manager configuration (#96) * Init * Refactor subagents --- .claude/settings.json | 15 ------ .gitignore | 2 + .mcp.json | 10 ---- CLAUDE.md | 2 +- flake.lock | 6 +-- modules/home/all/terminal.nix | 3 -- modules/home/claude-code/default.nix | 49 +++++++++++++++++++ .../home/claude-code}/subagents/pre-commit.md | 5 ++ modules/home/default.nix | 2 +- 9 files changed, 61 insertions(+), 33 deletions(-) delete mode 100644 .claude/settings.json delete mode 100644 .mcp.json create mode 100644 modules/home/claude-code/default.nix rename {.claude => modules/home/claude-code}/subagents/pre-commit.md (85%) diff --git a/.claude/settings.json b/.claude/settings.json deleted file mode 100644 index b456bad..0000000 --- a/.claude/settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "enableAllProjectMcpServers": true, - "permissions": { - "defaultMode": "plan", - "allow": [ - // Nix - "Bash(nix develop:*)", - "Bash(nix build:*)", - "Bash(om ci)", - - // Read files - "Bash(rg:*)" - ] - } -} diff --git a/.gitignore b/.gitignore index 2119e67..75b774d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /result /.direnv /.pre-commit-config.yaml + +/.claude/settings.local.json \ No newline at end of file diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index ddde848..0000000 --- a/.mcp.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "mcpServers": { - "nixos-mcp": { - "command": "uvx", - "args": [ - "mcp-nixos" - ] - } - } -} \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 76dfda0..687a5ed 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,4 +1,4 @@ ## Local CI -- You can test your changes by running `om ci` locally. \ No newline at end of file +- You can test your changes by running `nix build` on the relevant configuration. \ No newline at end of file diff --git a/flake.lock b/flake.lock index de76491..927bc63 100644 --- a/flake.lock +++ b/flake.lock @@ -1402,11 +1402,11 @@ ] }, "locked": { - "lastModified": 1753563501, - "narHash": "sha256-w8dykt5g06EB3yD/knx55MqsXvVHsoXfUbuBEWvT5H4=", + "lastModified": 1756319815, + "narHash": "sha256-a/TrhQh+U43XjcJZehq3/rjb5UXiyaJljQRoFLU1KyM=", "owner": "juspay", "repo": "vertex", - "rev": "7917e3f0e755bc32fd29a7593b630ee74f26c692", + "rev": "b8ee43c50a021514f4694c018bc9dd989ba2c47f", "type": "github" }, "original": { diff --git a/modules/home/all/terminal.nix b/modules/home/all/terminal.nix index c6bbbb2..6659bee 100644 --- a/modules/home/all/terminal.nix +++ b/modules/home/all/terminal.nix @@ -36,7 +36,6 @@ in # AI gemini-cli google-cloud-sdk - inputs.vertex.packages.${pkgs.system}.default # Publishing asciinema @@ -69,8 +68,6 @@ in lg = "lazygit"; l = "ls"; beep = "say 'beep'"; - - claude = "vertex-claude"; }; programs = { diff --git a/modules/home/claude-code/default.nix b/modules/home/claude-code/default.nix new file mode 100644 index 0000000..eee4286 --- /dev/null +++ b/modules/home/claude-code/default.nix @@ -0,0 +1,49 @@ +{ flake, pkgs, lib, ... }: +let + subagentsDir = ./subagents; + agents = lib.flip lib.mapAttrs' (lib.filterAttrs (fileName: fileType: fileType == "regular" && lib.hasSuffix ".md" fileName) (builtins.readDir subagentsDir)) + (fileName: _: lib.nameValuePair (lib.removeSuffix ".md" fileName) (builtins.readFile (subagentsDir + "/${fileName}"))); +in +{ + programs.claude-code = { + enable = true; + + # Wrapped Claude Code with Google Vertex AI auth + # See https://github.com/juspay/vertex + package = flake.inputs.vertex.packages.${pkgs.system}.default; + + # Basic settings for Claude Code + settings = { + enableAllProjectMcpServers = true; + permissions = { + defaultMode = "plan"; + allow = [ + "Bash(nix develop:*)" + "Bash(nix build:*)" + "Bash(om ci)" + "Bash(rg:*)" + ]; + }; + }; + + # Custom commands can be added here + commands = { + "om-ci" = '' + #!/bin/bash + # Run local CI (Nix) + om ci + ''; + }; + + # Automatically discovered agents from subagents/ directory + agents = agents; + + # MCP servers configuration + mcpServers = { + "nixos-mcp" = { + command = "uvx"; + args = [ "mcp-nixos" ]; + }; + }; + }; +} diff --git a/.claude/subagents/pre-commit.md b/modules/home/claude-code/subagents/pre-commit.md similarity index 85% rename from .claude/subagents/pre-commit.md rename to modules/home/claude-code/subagents/pre-commit.md index 97f890a..b955600 100644 --- a/.claude/subagents/pre-commit.md +++ b/modules/home/claude-code/subagents/pre-commit.md @@ -1,3 +1,8 @@ +--- +name: pre-commit +description: Invoke after changing sources locally, and only if git-hooks.nix is used by Nix. +tools: Bash +--- # Pre-commit Quality Check Agent ## Purpose diff --git a/modules/home/default.nix b/modules/home/default.nix index c5e1e57..bfdc022 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -13,6 +13,6 @@ ./all/just.nix ./all/juspay.nix - ./all/_1password.nix + ./claude-code ]; }