Compare commits

...

6 Commits

Author SHA1 Message Date
95aeff28ad Merge pull request 'feature/agent-git-identity' (#16) from feature/agent-git-identity into master
Reviewed-on: #16
2026-04-27 17:56:26 +02:00
m3tm3re
fa339ae8cc fix(agents): correct shared-options.nix import paths from ../ to ./ 2026-04-27 13:17:11 +02:00
m3tm3re
cec0c31d91 fix(agents): correct shared-options.nix import path 2026-04-27 13:11:11 +02:00
m3tm3re
6a8360305d fix(agents): remove shared-options.nix from imports to avoid module system conflict 2026-04-27 13:08:40 +02:00
m3tm3re
5edd0929d0 fix(agents): correct import paths for shared module 2026-04-27 13:00:52 +02:00
m3tm3re
60aeec7cfe feat(agents): add gitIdentity module
- Renamed shared-options.nix to shared/shared-options.nix
- Created shared/default.nix importing git-identity.nix and shared-options.nix
- Created shared/git-identity.nix with gitIdentity option set:
  - enable: Toggle for agent git identity
  - name: Git author name (default: m3ta-chiron)
  - email: Git author email (default: m3ta-chiron@agentmail.to)
  - signingKey: Optional GPG signing key path
  - sshKey: SSH private key path for git push auth
- Updated opencode.nix, pi.nix, claude-code.nix to import shared/default.nix
- Restructured modules to follow proper Nix module syntax with imports at top level
2026-04-27 12:43:56 +02:00
7 changed files with 129 additions and 48 deletions

View File

@@ -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}";
};
});
}
}

View File

@@ -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 {

View File

@@ -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";
};
};
}
}

View File

@@ -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
];
});
}
}

View File

@@ -0,0 +1,7 @@
# Shared agent module exports
# Imports all shared modules for the coding.agents namespace.
{
imports = [
./git-identity.nix
];
}

View 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";
};
};
}