56 lines
1.7 KiB
Nix
56 lines
1.7 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
shared = import ./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 ''
|
|
The `agents` flake input (your personal AGENTS repo).
|
|
When set, agents are rendered from canonical agent.toml files
|
|
and symlinked to ~/.config/opencode/agents/.
|
|
'';
|
|
|
|
modelOverrides = shared.mkModelOverridesOption;
|
|
};
|
|
|
|
config = mkIf config.coding.agents.opencode.enable {
|
|
# Rendered agent files symlinked to ~/.config/opencode/agents/
|
|
xdg.configFile."opencode/agents" = let
|
|
cfg = config.coding.agents.opencode;
|
|
in
|
|
mkIf (cfg.agentsInput != null) {
|
|
source = (import ../../../../lib {inherit lib;}).agents.renderForOpencode {
|
|
inherit pkgs;
|
|
canonical = cfg.agentsInput.lib.loadAgents;
|
|
modelOverrides = cfg.modelOverrides;
|
|
};
|
|
};
|
|
|
|
# Static config dirs from AGENTS repo
|
|
xdg.configFile."opencode/context" = let
|
|
cfg = config.coding.agents.opencode;
|
|
in
|
|
mkIf (cfg.agentsInput != null) {
|
|
source = "${cfg.agentsInput}/context";
|
|
};
|
|
xdg.configFile."opencode/commands" = let
|
|
cfg = config.coding.agents.opencode;
|
|
in
|
|
mkIf (cfg.agentsInput != null) {
|
|
source = "${cfg.agentsInput}/commands";
|
|
};
|
|
xdg.configFile."opencode/prompts" = let
|
|
cfg = config.coding.agents.opencode;
|
|
in
|
|
mkIf (cfg.agentsInput != null) {
|
|
source = "${cfg.agentsInput}/prompts";
|
|
};
|
|
};
|
|
}
|