feature/agent-git-identity #16
@@ -3,14 +3,16 @@
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
shared = import ./shared-options.nix {inherit lib;};
|
||||
in
|
||||
with lib; let
|
||||
cfg = config.coding.agents.claude-code;
|
||||
}: {
|
||||
imports = [
|
||||
./shared/default.nix
|
||||
];
|
||||
|
||||
options.coding.agents.claude-code = let
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
mcpCfg = config.programs.mcp or null;
|
||||
in {
|
||||
options.coding.agents.claude-code = {
|
||||
in
|
||||
with lib; {
|
||||
enable = mkEnableOption "Claude Code agent management via canonical agent.toml definitions";
|
||||
|
||||
agentsInput = shared.mkAgentsInputOption ''
|
||||
@@ -38,9 +40,12 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (let
|
||||
config = with lib; let
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
cfg = config.coding.agents.claude-code;
|
||||
agentsLib = (import ../../../../lib {inherit lib;}).agents;
|
||||
|
||||
in
|
||||
mkIf cfg.enable (let
|
||||
# Rendered agents + permissions (only if agentsInput is set)
|
||||
rendered = mkIf (cfg.agentsInput != null) (
|
||||
agentsLib.renderForClaudeCode {
|
||||
@@ -86,4 +91,4 @@ in
|
||||
source = "${settingsJson}";
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
shared = import ./shared-options.nix {inherit lib;};
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
cfg = config.coding.agents.skills;
|
||||
mkIf = lib.mkIf;
|
||||
in {
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
shared = import ./shared-options.nix {inherit lib;};
|
||||
in
|
||||
}: {
|
||||
imports = [
|
||||
./shared/default.nix
|
||||
];
|
||||
|
||||
options.coding.agents.opencode = let
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
in
|
||||
with lib; {
|
||||
options.coding.agents.opencode = {
|
||||
enable = mkEnableOption "OpenCode agent management via canonical agent.toml definitions";
|
||||
|
||||
agentsInput = shared.mkAgentsInputOption ''
|
||||
@@ -19,13 +23,17 @@ in
|
||||
modelOverrides = shared.mkModelOverridesOption;
|
||||
};
|
||||
|
||||
config = mkIf config.coding.agents.opencode.enable {
|
||||
# Rendered agent files symlinked to ~/.config/opencode/agents/
|
||||
xdg.configFile."opencode/agents" = let
|
||||
config = with lib; let
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
cfg = config.coding.agents.opencode;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
# Rendered agent files symlinked to ~/.config/opencode/agents/
|
||||
xdg.configFile."opencode/agents" = let
|
||||
agentsLib = (import ../../../../lib {inherit lib;}).agents;
|
||||
in
|
||||
mkIf (cfg.agentsInput != null) {
|
||||
source = (import ../../../../lib {inherit lib;}).agents.renderForOpencode {
|
||||
source = agentsLib.renderForOpencode {
|
||||
inherit pkgs;
|
||||
canonical = cfg.agentsInput.lib.loadAgents;
|
||||
modelOverrides = cfg.modelOverrides;
|
||||
@@ -33,23 +41,14 @@ in
|
||||
};
|
||||
|
||||
# Static config dirs from AGENTS repo
|
||||
xdg.configFile."opencode/context" = let
|
||||
cfg = config.coding.agents.opencode;
|
||||
in
|
||||
mkIf (cfg.agentsInput != null) {
|
||||
xdg.configFile."opencode/context" = mkIf (cfg.agentsInput != null) {
|
||||
source = "${cfg.agentsInput}/context";
|
||||
};
|
||||
xdg.configFile."opencode/commands" = let
|
||||
cfg = config.coding.agents.opencode;
|
||||
in
|
||||
mkIf (cfg.agentsInput != null) {
|
||||
xdg.configFile."opencode/commands" = mkIf (cfg.agentsInput != null) {
|
||||
source = "${cfg.agentsInput}/commands";
|
||||
};
|
||||
xdg.configFile."opencode/prompts" = let
|
||||
cfg = config.coding.agents.opencode;
|
||||
in
|
||||
mkIf (cfg.agentsInput != null) {
|
||||
xdg.configFile."opencode/prompts" = mkIf (cfg.agentsInput != null) {
|
||||
source = "${cfg.agentsInput}/prompts";
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,16 @@
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
shared = import ./shared-options.nix {inherit lib;};
|
||||
in
|
||||
with lib; let
|
||||
cfg = config.coding.agents.pi;
|
||||
}: {
|
||||
imports = [
|
||||
./shared/default.nix
|
||||
];
|
||||
|
||||
options.coding.agents.pi = let
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
mcpCfg = config.programs.mcp or null;
|
||||
in {
|
||||
options.coding.agents.pi = {
|
||||
in
|
||||
with lib; {
|
||||
enable = mkEnableOption "Pi agent management via canonical agent.toml definitions";
|
||||
|
||||
mcpServers = mkOption {
|
||||
@@ -202,7 +204,11 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (let
|
||||
config = with lib; let
|
||||
shared = import ./shared/shared-options.nix {inherit lib;};
|
||||
cfg = config.coding.agents.pi;
|
||||
in
|
||||
mkIf cfg.enable (let
|
||||
# Build settings.json by filtering out null values recursively
|
||||
filterNulls = attrs:
|
||||
lib.filterAttrs (_: v: v != null) (
|
||||
@@ -281,4 +287,4 @@ in
|
||||
agentFiles
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
7
modules/home-manager/coding/agents/shared/default.nix
Normal file
7
modules/home-manager/coding/agents/shared/default.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
# Shared agent module exports
|
||||
# Imports all shared modules for the coding.agents namespace.
|
||||
{
|
||||
imports = [
|
||||
./git-identity.nix
|
||||
];
|
||||
}
|
||||
64
modules/home-manager/coding/agents/shared/git-identity.nix
Normal file
64
modules/home-manager/coding/agents/shared/git-identity.nix
Normal file
@@ -0,0 +1,64 @@
|
||||
# Git identity module for agent commits.
|
||||
# Sets GIT_AUTHOR_*, GIT_COMMITTER_*, and GIT_SSH_COMMAND environment variables.
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.coding.agents.gitIdentity;
|
||||
in {
|
||||
options.coding.agents.gitIdentity = {
|
||||
enable = lib.mkEnableOption ''
|
||||
Agent Git identity for commits. When enabled, sets GIT_AUTHOR_* and
|
||||
GIT_COMMITTER_* environment variables for consistent bot identity.
|
||||
'';
|
||||
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "m3ta-chiron";
|
||||
description = "Git user name for agent commits.";
|
||||
example = "m3ta-chiron";
|
||||
};
|
||||
|
||||
email = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "m3ta-chiron@agentmail.to";
|
||||
description = "Git email for agent commits.";
|
||||
example = "m3ta-chiron@agentmail.to";
|
||||
};
|
||||
|
||||
signingKey = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
Optional GPG signing key for verified commits.
|
||||
Set to null to disable signing.
|
||||
'';
|
||||
example = "/home/user/.gnupg/sign_key.gpg";
|
||||
};
|
||||
|
||||
sshKey = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
Path to SSH private key for git push authentication.
|
||||
Use agenix-managed paths like /run/agenix/m3ta-chiron-ssh-key
|
||||
for secure secret management.
|
||||
'';
|
||||
example = "/run/agenix/m3ta-chiron-ssh-key";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.sessionVariables = {
|
||||
# Git author/committer identity
|
||||
GIT_AUTHOR_NAME = cfg.name;
|
||||
GIT_AUTHOR_EMAIL = cfg.email;
|
||||
GIT_COMMITTER_NAME = cfg.name;
|
||||
GIT_COMMITTER_EMAIL = cfg.email;
|
||||
|
||||
# SSH command for git push
|
||||
GIT_SSH_COMMAND = "ssh -i ${cfg.sshKey} -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user