~ruther/agent-environments

ref: ab16fba94379569e500f34e06f04081fa32bf9c2 agent-environments/modules/codex.nix -rw-r--r-- 965 bytes
ab16fba9 — František Boháček Add task tracker 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.codex;
  profile = "agent-environments";
  settingsFile = (pkgs.formats.toml { }).generate "codex-${profile}.config.toml" cfg.settings;
in
{
  options.codex = {
    enable = lib.mkEnableOption "Codex";
    package = lib.mkOption {
      type = lib.types.package;
      description = "The Codex package; must provide bin/codex.";
    };
    settings = lib.mkOption {
      type = (pkgs.formats.toml { }).type;
      default = { };
      description = "Settings layered over the account's config.toml as the '${profile}' profile.";
    };
  };

  config.build.agents.codex = lib.mkIf cfg.enable {
    exe = lib.getExe' cfg.package "codex";
    stateEnvVar = "CODEX_HOME";
    instructionsFile = "AGENTS.md";
    files = lib.optionalAttrs (cfg.settings != { }) {
      "${profile}.config.toml" = settingsFile;
    };
    flags = lib.optionals (cfg.settings != { }) [
      "--profile"
      profile
    ];
  };
}