codex: stop duplicating hook script deployment
Write path-backed hook bundles only under the active Codex home so XDG mode no longer mirrors scripts into ~/.codex.
This commit is contained in:
parent
52f93adbac
commit
cd863288d4
5 changed files with 27 additions and 12 deletions
|
|
@ -42,7 +42,6 @@ in
|
|||
configDir = if useXdgDirectories then "${xdgConfigHome}/codex" else ".codex";
|
||||
configFileName = if isTomlConfig then "config.toml" else "config.yaml";
|
||||
skillsDir = "${configDir}/skills";
|
||||
hookScriptDirs = [ "${configDir}/hooks" ] ++ lib.optional useXdgDirectories ".codex/hooks";
|
||||
pluginsMarketplaceName = "home-manager";
|
||||
pluginsDir = "${configDir}/plugins";
|
||||
pluginsCacheDir = "${pluginsDir}/cache";
|
||||
|
|
@ -218,7 +217,7 @@ in
|
|||
};
|
||||
}
|
||||
// lib.optionalAttrs hooksAreDir (
|
||||
lib.genAttrs hookScriptDirs (_: {
|
||||
lib.genAttrs [ "${configDir}/hooks" ] (_: {
|
||||
source = cfg.hooks;
|
||||
recursive = true;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -140,10 +140,11 @@ in
|
|||
|
||||
Directory values install {file}`hooks.json` to
|
||||
{file}`CODEX_HOME/hooks.json` and install the full directory to
|
||||
{file}`CODEX_HOME/hooks` so commands can reference bundled scripts.
|
||||
When {option}`home.preferXdgDirectories` is enabled, the hook
|
||||
directory is also installed to {file}`~/.codex/hooks` for upstream
|
||||
compatibility.
|
||||
the active Codex home hooks directory. In the default layout, commands
|
||||
can reference bundled scripts with paths such as
|
||||
{file}`$HOME/.codex/hooks/my-hook`. When
|
||||
{option}`home.preferXdgDirectories` is enabled, use
|
||||
{file}`$CODEX_HOME/hooks/my-hook`.
|
||||
|
||||
Hooks can also be configured inline through
|
||||
{option}`programs.codex.settings.hooks`; prefer using only one hook
|
||||
|
|
|
|||
|
|
@ -3,20 +3,18 @@
|
|||
|
||||
programs.codex = {
|
||||
enable = true;
|
||||
hooks = ./hooks-dir;
|
||||
hooks = ./hooks-dir-xdg;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/codex/hooks.json
|
||||
assertFileContent home-files/.config/codex/hooks.json \
|
||||
${./hooks-dir/hooks.json}
|
||||
${./hooks-dir-xdg/hooks.json}
|
||||
|
||||
assertFileExists home-files/.config/codex/hooks/session-start.sh
|
||||
assertFileContent home-files/.config/codex/hooks/session-start.sh \
|
||||
${./hooks-dir/session-start.sh}
|
||||
${./hooks-dir-xdg/session-start.sh}
|
||||
|
||||
assertFileExists home-files/.codex/hooks/session-start.sh
|
||||
assertFileContent home-files/.codex/hooks/session-start.sh \
|
||||
${./hooks-dir/session-start.sh}
|
||||
assertPathNotExists home-files/.codex/hooks
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
15
tests/modules/programs/codex/hooks-dir-xdg/hooks.json
Normal file
15
tests/modules/programs/codex/hooks-dir-xdg/hooks.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"hooks": {
|
||||
"SessionStart": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "$CODEX_HOME/hooks/session-start.sh",
|
||||
"timeout": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
printf '%s\n' '{"hookSpecificOutput":{"additionalContext":"Loaded from Home Manager hook bundle"}}'
|
||||
Loading…
Add table
Add a link
Reference in a new issue