From 680a967f21178fb6e88da2b3ef82c51c85dfc860 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sat, 28 Feb 2026 10:14:33 -0600 Subject: [PATCH] codex: fix skills location for new version Recently changed location where codex looks for skills. Version gate where we install the skills. Signed-off-by: Austin Horstman --- modules/programs/codex.nix | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/programs/codex.nix b/modules/programs/codex.nix index 68be40b7..14662db1 100644 --- a/modules/programs/codex.nix +++ b/modules/programs/codex.nix @@ -12,8 +12,9 @@ let tomlFormat = pkgs.formats.toml { }; yamlFormat = pkgs.formats.yaml { }; - packageVersion = if cfg.package != null then lib.getVersion cfg.package else "0.2.0"; + packageVersion = if cfg.package != null then lib.getVersion cfg.package else "0.94.0"; isTomlConfig = lib.versionAtLeast packageVersion "0.2.0"; + isAgentsSkillsSupported = lib.versionAtLeast packageVersion "0.94.0"; settingsFormat = if isTomlConfig then tomlFormat else yamlFormat; in { @@ -98,12 +99,16 @@ in If an attribute set is used, the attribute name becomes the skill directory name, and the value is either: - - Inline content as a string (creates {file}`skills//SKILL.md`) - - A path to a file (creates {file}`skills//SKILL.md`) - - A path to a directory (creates {file}`skills//` with all files) + - Inline content as a string (creates {file}`//SKILL.md`) + - A path to a file (creates {file}`//SKILL.md`) + - A path to a directory (creates {file}`//` with all files) If a path is used, it is expected to contain one folder per skill name, each - containing a {file}`SKILL.md`. The directory is symlinked to {file}`skills/`. + containing a {file}`SKILL.md`. The directory is symlinked to {file}`/`. + + The skills target directory depends on Codex version: + - {file}`~/.agents/skills` for Codex >= 0.94.0 + - {file}`~/.codex/skills` for older versions ''; example = lib.literalExpression '' { @@ -138,6 +143,7 @@ in xdgConfigHome = lib.removePrefix config.home.homeDirectory config.xdg.configHome; configDir = if useXdgDirectories then "${xdgConfigHome}/codex" else ".codex"; configFileName = if isTomlConfig then "config.toml" else "config.yaml"; + skillsDir = if isAgentsSkillsSupported then ".agents/skills" else "${configDir}/skills"; transformedMcpServers = lib.optionalAttrs (cfg.enableMcpIntegration && config.programs.mcp.enable) ( lib.mapAttrs ( @@ -183,7 +189,7 @@ in "${configDir}/AGENTS.md" = lib.mkIf (cfg.custom-instructions != "") { text = cfg.custom-instructions; }; - "${configDir}/skills" = lib.mkIf (lib.isPath cfg.skills) { + "${skillsDir}" = lib.mkIf (lib.isPath cfg.skills) { source = cfg.skills; recursive = true; }; @@ -191,12 +197,12 @@ in // (lib.mapAttrs' ( name: content: if lib.isPath content && lib.pathIsDirectory content then - lib.nameValuePair "${configDir}/skills/${name}" { + lib.nameValuePair "${skillsDir}/${name}" { source = content; recursive = true; } else - lib.nameValuePair "${configDir}/skills/${name}/SKILL.md" ( + lib.nameValuePair "${skillsDir}/${name}/SKILL.md" ( if lib.isPath content then { source = content; } else { text = content; } ) ) (if builtins.isAttrs cfg.skills then cfg.skills else { }));