mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-29 21:51:01 +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:
parent
cc7407839d
commit
502d9b7d30
10 changed files with 88 additions and 10 deletions
|
|
@ -9,7 +9,13 @@ let
|
||||||
|
|
||||||
cfg = config.programs.codex;
|
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
|
in
|
||||||
{
|
{
|
||||||
meta.maintainers = [
|
meta.maintainers = [
|
||||||
|
|
@ -24,16 +30,16 @@ in
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
inherit (settingsFormat) type;
|
inherit (settingsFormat) type;
|
||||||
description = ''
|
description = ''
|
||||||
Configuration written to {file}`~/.codex/config.yaml`.
|
Configuration written to {file}`~/.codex/config.toml` (0.2.0+) or {file}`~/.codex/config.yaml` (<0.2.0).
|
||||||
See <https://github.com/openai/codex#configuration-guide> for supported values.
|
See <https://github.com/openai/codex/blob/main/codex-rs/config.md> for supported values.
|
||||||
'';
|
'';
|
||||||
default = { };
|
default = { };
|
||||||
defaultText = lib.literalExpression "{ }";
|
defaultText = lib.literalExpression "{ }";
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
{
|
{
|
||||||
model = "gemma3:latest";
|
model = "gemma3:latest";
|
||||||
provider = "ollama";
|
model_provider = "ollama";
|
||||||
providers = {
|
model_providers = {
|
||||||
ollama = {
|
ollama = {
|
||||||
name = "Ollama";
|
name = "Ollama";
|
||||||
baseURL = "http://localhost:11434/v1";
|
baseURL = "http://localhost:11434/v1";
|
||||||
|
|
@ -59,8 +65,12 @@ in
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
home.file = {
|
home.file = {
|
||||||
".codex/config.yaml".source = settingsFormat.generate "codex-config" cfg.settings;
|
"${configFileName}" = lib.mkIf (cfg.settings != { }) {
|
||||||
".codex/AGENTS.md".text = cfg.custom-instructions;
|
source = settingsFormat.generate "codex-config" cfg.settings;
|
||||||
|
};
|
||||||
|
".codex/AGENTS.md" = lib.mkIf (cfg.custom-instructions != "") {
|
||||||
|
text = cfg.custom-instructions;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
7
tests/modules/programs/codex/config.toml
Normal file
7
tests/modules/programs/codex/config.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
model = "gemma3:latest"
|
||||||
|
model_provider = "ollama"
|
||||||
|
|
||||||
|
[model_providers.ollama]
|
||||||
|
baseURL = "http://localhost:11434/v1"
|
||||||
|
envKey = "OLLAMA_API_KEY"
|
||||||
|
name = "Ollama"
|
||||||
|
|
@ -9,6 +9,6 @@
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.codex/AGENTS.md
|
assertFileExists home-files/.codex/AGENTS.md
|
||||||
assertFileContent home-files/.codex/AGENTS.md \
|
assertFileContent home-files/.codex/AGENTS.md \
|
||||||
${./custom-instructions.md}
|
${./AGENTS.md}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
codex-settings = ./settings.nix;
|
codex-settings-toml = ./settings-toml.nix;
|
||||||
|
codex-settings-yaml = ./settings-yaml.nix;
|
||||||
|
codex-empty-settings = ./empty-settings.nix;
|
||||||
codex-custom-instructions = ./custom-instructions.nix;
|
codex-custom-instructions = ./custom-instructions.nix;
|
||||||
|
codex-empty-custom-instructions = ./empty-custom-instructions.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
programs.codex = {
|
||||||
|
enable = true;
|
||||||
|
custom-instructions = "";
|
||||||
|
};
|
||||||
|
nmt.script = ''
|
||||||
|
assertPathNotExists home-files/.codex/AGENTS.md
|
||||||
|
'';
|
||||||
|
}
|
||||||
10
tests/modules/programs/codex/empty-settings.nix
Normal file
10
tests/modules/programs/codex/empty-settings.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
programs.codex = {
|
||||||
|
enable = true;
|
||||||
|
settings = { };
|
||||||
|
};
|
||||||
|
nmt.script = ''
|
||||||
|
assertPathNotExists home-files/.codex/config.toml
|
||||||
|
assertPathNotExists home-files/.codex/config.yaml
|
||||||
|
'';
|
||||||
|
}
|
||||||
30
tests/modules/programs/codex/settings-toml.nix
Normal file
30
tests/modules/programs/codex/settings-toml.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
codexPackage = pkgs.runCommand "codex-0.2.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 = "gemma3:latest";
|
||||||
|
model_provider = "ollama";
|
||||||
|
model_providers = {
|
||||||
|
ollama = {
|
||||||
|
name = "Ollama";
|
||||||
|
baseURL = "http://localhost:11434/v1";
|
||||||
|
envKey = "OLLAMA_API_KEY";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.codex/config.toml
|
||||||
|
assertFileContent home-files/.codex/config.toml \
|
||||||
|
${./config.toml}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
codexPackage = pkgs.runCommand "codex-0.1.2504301751" { } ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
echo '#!/bin/sh' > $out/bin/codex
|
||||||
|
chmod +x $out/bin/codex
|
||||||
|
'';
|
||||||
|
in
|
||||||
{
|
{
|
||||||
programs.codex = {
|
programs.codex = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
package = codexPackage;
|
||||||
settings = {
|
settings = {
|
||||||
model = "gemma3:latest";
|
model = "gemma3:latest";
|
||||||
provider = "ollama";
|
provider = "ollama";
|
||||||
|
|
@ -16,6 +25,6 @@
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.codex/config.yaml
|
assertFileExists home-files/.codex/config.yaml
|
||||||
assertFileContent home-files/.codex/config.yaml \
|
assertFileContent home-files/.codex/config.yaml \
|
||||||
${./settings.yml}
|
${./config.yaml}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue