Files
home-manager/tests/modules/programs/codex/profiles.nix
Austin Horstman d456f483f1 codex: add profile config support
Codex 0.134.0 stopped reading profile settings from [profiles.<name>] in config.toml and no longer supports the top-level profile selector.

Add a dedicated programs.codex.profiles option so Home Manager can write CODEX_HOME/<name>.config.toml files that match the current CLI --profile behavior. For Codex 0.134.0 and later, legacy programs.codex.settings.profiles entries are migrated into profile files with a warning, and removed legacy profile keys are omitted from config.toml so strict config loading keeps working. Older Codex versions keep the legacy config shape.
2026-06-18 08:19:47 -05:00

44 lines
1.1 KiB
Nix

{ pkgs, ... }:
let
codexPackage = pkgs.runCommand "codex-0.134.0" { } ''
mkdir -p $out/bin
echo '#!/bin/sh' > $out/bin/codex
chmod +x $out/bin/codex
'';
in
{
programs.codex = {
enable = true;
package = codexPackage;
settings = {
model = "gpt-5";
};
profiles = {
deep-review = {
approval_policy = "on-request";
model = "gpt-5.5";
model_reasoning_effort = "xhigh";
sandbox_mode = "workspace-write";
};
ci = {
approval_policy = "never";
sandbox_mode = "workspace-write";
};
};
};
test.asserts.warnings.expected = [ ];
nmt.script = ''
assertFileExists home-files/.codex/config.toml
assertFileContent home-files/.codex/config.toml \
${./profiles-config.toml}
assertFileExists home-files/.codex/deep-review.config.toml
assertFileContent home-files/.codex/deep-review.config.toml \
${./profiles-deep-review.toml}
assertFileExists home-files/.codex/ci.config.toml
assertFileContent home-files/.codex/ci.config.toml \
${./profiles-ci.toml}
'';
}