chore(codex): route Codex to OpenCode Go without clobbering ChatGPT auth
The ChatGPT desktop app owns and rewrites ~/.codex/config.toml, so symlinking that file into the repo leaked the app's own config (model, [desktop], [plugins], [mcp_servers]) into git and got clobbered on launch. - Stop symlinking ~/.codex/config.toml; keep it app-owned and merge the repo fragment home/.codex/config.toml into it on every activation (home.activation.codexOpenCodeGo + home/bin/codex-opencode-go-sync). - Replace requires_openai_auth with a command-backed token (~/.local/bin/opencode-go-token reads the key from the opencode store), so ~/.codex/auth.json stays in ChatGPT mode and ChatGPT sign-in coexists with Go. - Add the Codex 0.160+ profile file home/.codex/luna.config.toml (gpt-6-luna). - Declare the chatgpt + codex casks; document the decision in AGENTS.md. Verified: default deepseek-v4.1-flash and --profile luna both return over the Go Responses API while auth.json remains in chatgpt mode.
This commit is contained in:
1 parent
1f13c6eb1a
commit
6e0bc81e85
8 files changed
+152
No files matched your search
@@ -107,6 +107,21 @@ in
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
|
||||
force = true;
|
||||
};
|
||||
# Codex provider routing -> OpenCode Go. ~/.codex/config.toml is deliberately
|
||||
# NOT symlinked: the ChatGPT desktop app owns and rewrites that file. The repo
|
||||
# fragment home/.codex/config.toml is merged into it by
|
||||
# home.activation.codexOpenCodeGo instead. The provider's command-backed auth
|
||||
# runs this helper, which reads the key from the opencode store.
|
||||
home.file.".local/bin/opencode-go-token" = {
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/opencode-go-token";
|
||||
force = true;
|
||||
};
|
||||
# Codex 0.160+ profiles live in $CODEX_HOME/<name>.config.toml. The app does not
|
||||
# touch these, so they can be symlinked normally.
|
||||
home.file.".codex/luna.config.toml" = {
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/.codex/luna.config.toml";
|
||||
force = true;
|
||||
};
|
||||
home.file.".config/opencode/AGENTS.md" = {
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
|
||||
force = true;
|
||||
@@ -246,6 +261,19 @@ in
|
||||
ln -sfn "${dotfiles}/home/bin/sync-music" "$HOME/.local/bin/sync-music"
|
||||
'';
|
||||
|
||||
# Codex (desktop app + CLI) -> OpenCode Go. The ChatGPT app owns and rewrites
|
||||
# ~/.codex/config.toml, so it must not be a symlink into the repo. Merge the
|
||||
# repo fragment into the live file on every activation instead; the app's own
|
||||
# sections survive. See home/bin/codex-opencode-go-sync.
|
||||
home.activation.codexOpenCodeGo = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
set -euo pipefail
|
||||
mkdir -p "$HOME/.codex"
|
||||
${pkgs.python3.withPackages (ps: [ ps.tomlkit ])}/bin/python3 \
|
||||
"${dotfiles}/home/bin/codex-opencode-go-sync" \
|
||||
"${dotfiles}/home/.codex/config.toml" \
|
||||
"$HOME/.codex/config.toml"
|
||||
'';
|
||||
|
||||
# OpenCode 2 is not on Homebrew (beta). Install via Homebrew's npm, never
|
||||
# Nix's npm (EACCES on the store). Skip when already present so a rebuild
|
||||
# does not pull a new beta under a live TUI.
|
||||
|
||||
Reference in new issue
Block a user