mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-10 22:31:12 +00:00
programs.claude-code.hooks previously only accepted inline strings. It now shares the same either-lines-or-path content option used by agents, commands, and rules, so a hook script can be referenced from a file instead of being inlined. mkSourceEntry used lib.isPath, which does not match derivations such as pkgs.writeShellScript. Since lib.types.path accepts derivations, a derivation-backed hook (or agent, command, rule, or output style) sent the derivation to home.file.*.text and failed evaluation. Use lib.hm.strings.isPathLike instead, and add a derivation-backed hook test. No release-notes entry: other option additions/extensions to this module (e.g. path support for agents/commands, the rules option itself) haven't warranted one either.
65 lines
1.9 KiB
Nix
65 lines
1.9 KiB
Nix
{
|
|
programs.claude-code = {
|
|
enable = true;
|
|
commands = {
|
|
inline-command = ''
|
|
---
|
|
allowed-tools: Read
|
|
description: Inline command
|
|
---
|
|
This command is defined inline.
|
|
'';
|
|
path-command = ./test-command.md;
|
|
};
|
|
agents = {
|
|
inline-agent = ''
|
|
---
|
|
name: inline-agent
|
|
description: Inline agent
|
|
tools: Read
|
|
---
|
|
This agent is defined inline.
|
|
'';
|
|
path-agent = ./test-agent.md;
|
|
};
|
|
skills = {
|
|
inline-skill = ''
|
|
Use this skill when the user asks you to perform an inline operation.
|
|
|
|
## Instructions
|
|
This skill is defined inline.
|
|
'';
|
|
path-skill = ./test-skill.md;
|
|
};
|
|
hooks = {
|
|
inline-hook = ''
|
|
#!/usr/bin/env bash
|
|
echo "This hook is defined inline."
|
|
'';
|
|
path-hook = ./hooks/test-hook;
|
|
};
|
|
};
|
|
|
|
nmt.script = ''
|
|
assertFileExists home-files/.claude/commands/inline-command.md
|
|
assertFileExists home-files/.claude/commands/path-command.md
|
|
assertFileExists home-files/.claude/agents/inline-agent.md
|
|
assertFileExists home-files/.claude/agents/path-agent.md
|
|
assertFileExists home-files/.claude/skills/inline-skill/SKILL.md
|
|
assertFileExists home-files/.claude/skills/path-skill/SKILL.md
|
|
assertFileExists home-files/.claude/hooks/inline-hook
|
|
assertFileExists home-files/.claude/hooks/path-hook
|
|
|
|
assertFileContent home-files/.claude/commands/path-command.md \
|
|
${./test-command.md}
|
|
assertFileContent home-files/.claude/agents/path-agent.md \
|
|
${./test-agent.md}
|
|
assertFileContent home-files/.claude/skills/path-skill/SKILL.md \
|
|
${./test-skill.md}
|
|
assertFileContent home-files/.claude/hooks/path-hook \
|
|
${./hooks/test-hook}
|
|
assertFileIsExecutable home-files/.claude/hooks/inline-hook
|
|
assertFileIsExecutable home-files/.claude/hooks/path-hook
|
|
'';
|
|
}
|