Wrap T3 Code apps with optional agent CLI paths

- Split base desktop/server derivations from wrapper layers
- Add optional PATH injection for codex, claudeCode, and opencode
- Update flake inputs and lock entries for nixpkgs/llm-agents
This commit is contained in:
2026-04-28 12:47:38 +03:00
parent 71c3a101dd
commit cd931c951e
6 changed files with 102 additions and 54 deletions
+27 -13
View File
@@ -2,6 +2,7 @@
lib,
src,
stdenv,
symlinkJoin,
bun,
codex ? null,
claudeCode ? null,
@@ -28,11 +29,7 @@
pname = "t3code-server";
version = serverPackageJson.version;
in
assert lib.assertMsg (!withCodex || codex != null) "withCodex requires a codex package";
assert lib.assertMsg (!withClaudeCode || claudeCode != null) "withClaudeCode requires a claudeCode package";
assert lib.assertMsg (!withOpencode || opencode != null) "withOpencode requires an opencode package";
stdenv.mkDerivation (finalAttrs: {
basePackage = stdenv.mkDerivation (finalAttrs: {
inherit pname version;
inherit src;
@@ -116,13 +113,6 @@ in
cp -R --no-preserve=mode packages/shared "$out/libexec/t3code/packages/"
makeWrapper ${lib.getExe nodejs} "$out/bin/t3" \
${lib.optionalString withCodex ''
--prefix PATH : "${lib.makeBinPath [ codex ]}" \
''}${lib.optionalString withClaudeCode ''
--prefix PATH : "${lib.makeBinPath [ claudeCode ]}" \
''}${lib.optionalString withOpencode ''
--prefix PATH : "${lib.makeBinPath [ opencode ]}" \
''} \
--add-flags "$out/libexec/t3code/apps/server/dist/bin.mjs"
runHook postInstall
@@ -136,4 +126,28 @@ in
platforms = lib.platforms.unix;
sourceProvenance = with lib.sourceTypes; [fromSource];
};
})
});
withAgentPath = withCodex || withClaudeCode || withOpencode;
agentPath = lib.makeBinPath (
lib.optionals withCodex [codex]
++ lib.optionals withClaudeCode [claudeCode]
++ lib.optionals withOpencode [opencode]
);
in
assert lib.assertMsg (!withCodex || codex != null) "withCodex requires a codex package";
assert lib.assertMsg (!withClaudeCode || claudeCode != null) "withClaudeCode requires a claudeCode package";
assert lib.assertMsg (!withOpencode || opencode != null) "withOpencode requires an opencode package";
if withAgentPath
then
symlinkJoin {
inherit pname version;
name = "${pname}-${version}";
paths = [basePackage];
nativeBuildInputs = [makeBinaryWrapper];
postBuild = ''
wrapProgram "$out/bin/t3" \
--prefix PATH : "${agentPath}"
'';
meta = basePackage.meta;
}
else basePackage