1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

codex: starting with v0.2.0 codex uses a TOML configuration file (#7388)

Updated related settings and test files to reflect the new format.
This commit is contained in:
Thierry Delafontaine 2025-07-06 15:58:22 +02:00 committed by GitHub
parent cc7407839d
commit 502d9b7d30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 88 additions and 10 deletions

View file

@ -9,7 +9,13 @@ let
cfg = config.programs.codex;
settingsFormat = pkgs.formats.yaml { };
tomlFormat = pkgs.formats.toml { };
yamlFormat = pkgs.formats.yaml { };
packageVersion = if cfg.package != null then lib.getVersion cfg.package else "0.2.0";
isTomlConfig = lib.versionAtLeast packageVersion "0.2.0";
settingsFormat = if isTomlConfig then tomlFormat else yamlFormat;
configFileName = if isTomlConfig then ".codex/config.toml" else ".codex/config.yaml";
in
{
meta.maintainers = [
@ -24,16 +30,16 @@ in
settings = lib.mkOption {
inherit (settingsFormat) type;
description = ''
Configuration written to {file}`~/.codex/config.yaml`.
See <https://github.com/openai/codex#configuration-guide> for supported values.
Configuration written to {file}`~/.codex/config.toml` (0.2.0+) or {file}`~/.codex/config.yaml` (<0.2.0).
See <https://github.com/openai/codex/blob/main/codex-rs/config.md> for supported values.
'';
default = { };
defaultText = lib.literalExpression "{ }";
example = lib.literalExpression ''
{
model = "gemma3:latest";
provider = "ollama";
providers = {
model_provider = "ollama";
model_providers = {
ollama = {
name = "Ollama";
baseURL = "http://localhost:11434/v1";
@ -59,8 +65,12 @@ in
config = mkIf cfg.enable {
home.packages = mkIf (cfg.package != null) [ cfg.package ];
home.file = {
".codex/config.yaml".source = settingsFormat.generate "codex-config" cfg.settings;
".codex/AGENTS.md".text = cfg.custom-instructions;
"${configFileName}" = lib.mkIf (cfg.settings != { }) {
source = settingsFormat.generate "codex-config" cfg.settings;
};
".codex/AGENTS.md" = lib.mkIf (cfg.custom-instructions != "") {
text = cfg.custom-instructions;
};
};
};