A modules/claude.nix => modules/claude.nix +36 -0
@@ 0,0 1,36 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ cfg = config.claude;
+ settingsFile = (pkgs.formats.json { }).generate "claude-settings.json" cfg.settings;
+in
+{
+ options.claude = {
+ enable = lib.mkEnableOption "Claude Code";
+ package = lib.mkOption {
+ type = lib.types.package;
+ description = "The Claude Code package; must provide bin/claude.";
+ };
+ settings = lib.mkOption {
+ type = (pkgs.formats.json { }).type;
+ default = { };
+ description = "Settings layered over the account's settings.json via --settings.";
+ };
+ };
+
+ config.build.agents.claude = lib.mkIf cfg.enable {
+ exe = lib.getExe' cfg.package "claude";
+ stateEnvVar = "CLAUDE_CONFIG_DIR";
+ instructionsFile = "CLAUDE.md";
+ # Managed links: path relative to the state dir -> store path.
+ files = { };
+ flags = lib.optionals (cfg.settings != { }) [
+ "--settings"
+ "${settingsFile}"
+ ];
+ };
+}
A modules/codex.nix => modules/codex.nix +38 -0
@@ 0,0 1,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
+ ];
+ };
+}