claude-code: added 'commandsDir' option to specify commands from filesystem

This commit is contained in:
Sewer56 2025-08-22 22:13:07 +01:00 committed by Austin Horstman
parent a641bbbb9b
commit be37a3492d
5 changed files with 47 additions and 0 deletions

View file

@ -196,6 +196,16 @@ in
example = lib.literalExpression "./agents";
};
commandsDir = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Path to a directory containing command files for Claude Code.
Command files from this directory will be symlinked to .claude/commands/.
'';
example = lib.literalExpression "./commands";
};
mcpServers = lib.mkOption {
type = lib.types.attrsOf jsonFormat.type;
default = { };
@ -251,6 +261,10 @@ in
assertion = !(cfg.agents != { } && cfg.agentsDir != null);
message = "Cannot specify both `programs.claude-code.agents` and `programs.claude-code.agentsDir`";
}
{
assertion = !(cfg.commands != { } && cfg.commandsDir != null);
message = "Cannot specify both `programs.claude-code.commands` and `programs.claude-code.commandsDir`";
}
];
programs.claude-code.finalPackage =
@ -300,6 +314,11 @@ in
source = cfg.agentsDir;
recursive = true;
};
".claude/commands" = lib.mkIf (cfg.commandsDir != null) {
source = cfg.commandsDir;
recursive = true;
};
}
// lib.mapAttrs' (
name: content: