From 0c5a54499d4d2c941db960ba25e78b39d348399b Mon Sep 17 00:00:00 2001 From: Timo Bingmann Date: Thu, 13 Nov 2025 23:08:01 -0800 Subject: [PATCH] Add homeManagerModules.claude for Claude Code configuration management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a new home-manager module that provides declarative configuration management for Claude Code, Anthropic's official CLI tool. The module follows the established pattern used by other home-manager modules in this flake (default, private, macos, develop) and enables users to deploy custom Claude Code slash commands and configuration files to ~/.claude/. Changes included: 1. Created home/claude/config.nix module: - Defines a new home-manager module for Claude Code configuration - Uses home.file to deploy command files from the Nix store to ~/.claude/ - Currently deploys two custom slash commands to ~/.claude/commands/ 2. Added two custom slash commands: - commit.md: Automates git commit creation by reading staged diffs and generating comprehensive commit messages - go-plan.md: Writes detailed implementation plans to PLAN.md before starting work, supporting the planning workflow 3. Registered homeManagerModules.claude in flake.nix: - Added as a new, independent module group that can be imported separately - Positioned after the develop module for logical organization - Can be enabled by importing inputs.nix-shared.homeManagerModules.claude 4. Enhanced flake.nix documentation: - Added descriptive comments for all nixosModules and homeManagerModules - Clarifies the purpose of each module group (e.g., "Linux specific system configuration", "Add private homelab and cloud host aliases") - Improves maintainability and makes the flake structure self-documenting The module structure supports easy extension - additional slash commands or configuration files can be added by placing them in home/claude/config/ and adding corresponding home.file entries in config.nix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- flake.nix | 15 ++++++++++++++- home/claude/config.nix | 11 +++++++++++ home/claude/config/commands/commit.md | 1 + home/claude/config/commands/go-plan.md | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 home/claude/config.nix create mode 100644 home/claude/config/commands/commit.md create mode 100644 home/claude/config/commands/go-plan.md diff --git a/flake.nix b/flake.nix index a69919e..f087d7e 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ # Set up formatter. formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; - # System Modules + # Global all-hosts configuration nixosModules.default = { ... }: { imports = [ ./system/default/editor.nix @@ -20,6 +20,7 @@ ]; }; + # Linux specific system configuration nixosModules.linux = { ... }: { imports = [ ./system/linux/i18n.nix @@ -29,6 +30,7 @@ ]; }; + # MacOS specific system configuration nixosModules.macos = { ... }: { imports = [ ./system/macos/environment.nix @@ -40,6 +42,7 @@ ]; }; + # Tools on all development machines nixosModules.develop = { ... }: { imports = [ ./system/develop/packages.nix @@ -56,22 +59,32 @@ ]; }; + # Add private homelab and cloud host aliases homeManagerModules.private = { ... }: { imports = [ ./home/private/ssh-hosts.nix ]; }; + # MacOS specific home configuration homeManagerModules.macos = { ... }: { imports = [ ./home/macos/home.nix ]; }; + # Emacs Configuration homeManagerModules.develop = { ... }: { imports = [ ./home/develop/emacs.nix ]; }; + + # Claude Code configuration + homeManagerModules.claude = { ... }: { + imports = [ + ./home/claude/config.nix + ]; + }; }; } diff --git a/home/claude/config.nix b/home/claude/config.nix new file mode 100644 index 0000000..caf7265 --- /dev/null +++ b/home/claude/config.nix @@ -0,0 +1,11 @@ +{ lib, ... }: +{ + # Copy Claude Code configuration files to ~/.claude/ + # Using activation script instead of home.file to copy (not symlink) files + home.activation.copyClaudeCommands = lib.hm.dag.entryAfter ["writeBoundary"] '' + $DRY_RUN_CMD mkdir -p $VERBOSE_ARG $HOME/.claude/commands + $DRY_RUN_CMD cp $VERBOSE_ARG ${./config/commands/commit.md} $HOME/.claude/commands/commit.md + $DRY_RUN_CMD cp $VERBOSE_ARG ${./config/commands/go-plan.md} $HOME/.claude/commands/go-plan.md + $DRY_RUN_CMD chmod $VERBOSE_ARG 644 $HOME/.claude/commands/*.md + ''; +} diff --git a/home/claude/config/commands/commit.md b/home/claude/config/commands/commit.md new file mode 100644 index 0000000..c3e77b9 --- /dev/null +++ b/home/claude/config/commands/commit.md @@ -0,0 +1 @@ +Make another git commit -- read the git diff of staged files and write a good long description \ No newline at end of file diff --git a/home/claude/config/commands/go-plan.md b/home/claude/config/commands/go-plan.md new file mode 100644 index 0000000..e060781 --- /dev/null +++ b/home/claude/config/commands/go-plan.md @@ -0,0 +1 @@ +Write the detailed plan to PLAN.md and start. \ No newline at end of file