|
29 | 29 | path = "${codexConfigPath}/skills/.system/${name}/SKILL.md"; |
30 | 30 | enabled = false; |
31 | 31 | }) aiTools.codex.disabledSystemSkills; |
| 32 | + codexCommandSkillNames = builtins.attrNames aiTools.codex.commandSkillFiles; |
32 | 33 | codexAgentFiles = lib.mapAttrs' ( |
33 | 34 | name: agentSettings: |
34 | 35 | lib.nameValuePair "${codexConfigDir}/agents/${name}.toml" { |
35 | 36 | source = tomlFormat.generate "codex-agent-${name}" agentSettings; |
36 | 37 | } |
37 | 38 | ) aiTools.codex.agents; |
38 | | - codexCommandFiles = lib.concatMapAttrs ( |
| 39 | + codexCommandSkillDirs = lib.mapAttrs ( |
39 | 40 | name: commandFiles: |
40 | | - lib.mapAttrs' ( |
41 | | - relativePath: fileText: |
42 | | - lib.nameValuePair "${codexConfigDir}/skills/${name}/${relativePath}" { |
43 | | - text = fileText; |
44 | | - } |
45 | | - ) commandFiles |
| 41 | + pkgs.runCommandLocal "codex-command-skill-${name}" { } ( |
| 42 | + lib.concatStringsSep "\n" ( |
| 43 | + lib.mapAttrsToList ( |
| 44 | + relativePath: fileText: |
| 45 | + let |
| 46 | + file = builtins.toFile "codex-command-${name}-${lib.replaceStrings [ "/" ] [ "-" ] relativePath}" fileText; |
| 47 | + in |
| 48 | + '' |
| 49 | + install -Dm0644 ${file} "$out/${relativePath}" |
| 50 | + '' |
| 51 | + ) commandFiles |
| 52 | + ) |
| 53 | + ) |
46 | 54 | ) aiTools.codex.commandSkillFiles; |
| 55 | + codexSkills = aiTools.codex.skillSources // codexCommandSkillDirs; |
| 56 | + codexCommandSkillCleanup = lib.concatMapStringsSep "\n" ( |
| 57 | + name: |
| 58 | + let |
| 59 | + target = "${codexConfigPath}/skills/${name}"; |
| 60 | + in |
| 61 | + '' |
| 62 | + if [ -d ${lib.escapeShellArg target} ] && [ ! -L ${lib.escapeShellArg target} ]; then |
| 63 | + [ ! -L ${lib.escapeShellArg "${target}/SKILL.md"} ] || rm -f ${lib.escapeShellArg "${target}/SKILL.md"} |
| 64 | + [ ! -L ${lib.escapeShellArg "${target}/agents/openai.yaml"} ] || rm -f ${lib.escapeShellArg "${target}/agents/openai.yaml"} |
| 65 | + rmdir ${lib.escapeShellArg "${target}/agents"} 2>/dev/null || true |
| 66 | + rmdir ${lib.escapeShellArg target} 2>/dev/null || true |
| 67 | + fi |
| 68 | + '' |
| 69 | + ) codexCommandSkillNames; |
47 | 70 | codexProfiles = { |
48 | 71 | # Deep analysis and live-research mode. Intentionally expensive: |
49 | 72 | # benchmark preference is GPT-5.5 xhigh for best pass rate. |
|
124 | 147 | # codex bump does not block activation. The native-messaging manifest and |
125 | 148 | # node_repl MCP server are managed declaratively below, so the installer's |
126 | 149 | # manifest writes are redirected to a scratch root it may own. |
127 | | - activation = lib.mkIf pkgs.stdenv.hostPlatform.isLinux { |
| 150 | + activation = { |
| 151 | + codexCommandSkillShape = lib.hm.dag.entryBefore [ "checkLinkTargets" ] codexCommandSkillCleanup; |
| 152 | + } |
| 153 | + // lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { |
128 | 154 | codexBrowserUseInstall = lib.hm.dag.entryAfter [ "writeBoundary" ] '' |
129 | 155 | run ${lib.getExe pkgs.khanelinix.codex-browser-use-linux-chromium} install \ |
130 | 156 | --codex-home ${codexConfigPath} \ |
|
134 | 160 | || verboseEcho "codex-browser-use-linux-chromium install failed (non-fatal); run codex-browser-doctor" |
135 | 161 | ''; |
136 | 162 | }; |
137 | | - file = codexAgentFiles // codexCommandFiles; |
| 163 | + file = codexAgentFiles; |
138 | 164 | packages = lib.optionals pkgs.stdenv.hostPlatform.isLinux [ |
139 | 165 | pkgs.khanelinix.codex-browser-use-linux-chromium |
140 | 166 | ]; |
|
377 | 403 |
|
378 | 404 | context = builtins.readFile aiTools.base; |
379 | 405 | contextOverride = aiTools.codex.contextOverride; |
380 | | - inherit (aiTools.codex) skills; |
| 406 | + skills = codexSkills; |
381 | 407 | rules = import ./rules.nix; |
382 | 408 | }; |
383 | 409 | }; |
|
0 commit comments