mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
claude-code: mark hook scripts executable
Inline hooks are scripts, so write them with the executable bit set. Add NMT assertions covering default and custom config directories.
(cherry picked from commit d0af9b8bf3)
This commit is contained in:
@@ -558,10 +558,14 @@ in
|
||||
name: content: nameValuePair "${cfg.configDir}/${subdir}/${name}.md" (mkSourceEntry content)
|
||||
) attrs;
|
||||
|
||||
mkTextEntries =
|
||||
subdir: attrs:
|
||||
mkHookEntries =
|
||||
attrs:
|
||||
lib.mapAttrs' (
|
||||
name: content: nameValuePair "${cfg.configDir}/${subdir}/${name}" { text = content; }
|
||||
name: content:
|
||||
nameValuePair "${cfg.configDir}/hooks/${name}" {
|
||||
text = content;
|
||||
executable = true;
|
||||
}
|
||||
) attrs;
|
||||
|
||||
mkRecursiveDirAttrs =
|
||||
@@ -727,7 +731,7 @@ in
|
||||
recursive = true;
|
||||
};
|
||||
})
|
||||
(mkTextEntries "hooks" cfg.hooks)
|
||||
(mkHookEntries cfg.hooks)
|
||||
(lib.optionalAttrs (builtins.isAttrs cfg.skills) (lib.mapAttrs' mkSkillEntry cfg.skills))
|
||||
(mkMarkdownEntries "output-styles" cfg.outputStyles)
|
||||
];
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
assertFileExists home-files/.config/claude/commands/hello.md
|
||||
assertFileExists home-files/.config/claude/rules/style.md
|
||||
assertFileExists home-files/.config/claude/hooks/pre-edit
|
||||
assertFileIsExecutable home-files/.config/claude/hooks/pre-edit
|
||||
assertFileExists home-files/.config/claude/output-styles/concise.md
|
||||
assertFileExists home-files/.config/claude/skills/pdf/SKILL.md
|
||||
|
||||
|
||||
@@ -135,9 +135,11 @@
|
||||
assertFileContent home-files/.claude/commands/commit.md ${./expected-commit}
|
||||
|
||||
assertFileExists home-files/.claude/hooks/pre-edit
|
||||
assertFileIsExecutable home-files/.claude/hooks/pre-edit
|
||||
assertFileRegex home-files/.claude/hooks/pre-edit "About to edit file"
|
||||
|
||||
assertFileExists home-files/.claude/hooks/post-commit
|
||||
assertFileIsExecutable home-files/.claude/hooks/post-commit
|
||||
assertFileRegex home-files/.claude/hooks/post-commit "Committed with message"
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user