2026-03-30 19:04:24 +02:00
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
pkgs,
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
with lib; let
|
|
|
|
|
cfg = config.coding.opencode;
|
|
|
|
|
in {
|
|
|
|
|
options.coding.opencode = {
|
|
|
|
|
enable = mkEnableOption "opencode AI coding assistant";
|
|
|
|
|
|
|
|
|
|
ohMyOpencodeSettings = mkOption {
|
|
|
|
|
type = types.attrs;
|
|
|
|
|
default = {};
|
|
|
|
|
description = ''
|
|
|
|
|
Attributes merged (via recursiveUpdate) on top of the default
|
|
|
|
|
oh-my-opencode.json. Use this to set provider-specific model
|
|
|
|
|
assignments per machine.
|
|
|
|
|
'';
|
|
|
|
|
example = literalExpression ''
|
|
|
|
|
{
|
|
|
|
|
agents.sisyphus.model = "anthropic/claude-opus-4-5";
|
|
|
|
|
categories.ultrabrain.model = "anthropic/claude-opus-4-5";
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extraSettings = mkOption {
|
|
|
|
|
type = types.attrs;
|
|
|
|
|
default = {};
|
|
|
|
|
description = ''
|
|
|
|
|
Extra opencode settings merged (via mkMerge) into
|
|
|
|
|
programs.opencode.settings. Use this to add provider
|
|
|
|
|
configuration that is specific to a machine or organisation.
|
|
|
|
|
'';
|
|
|
|
|
example = literalExpression ''
|
|
|
|
|
{
|
|
|
|
|
provider.anthropic = {
|
|
|
|
|
name = "Anthropic";
|
|
|
|
|
models."claude-opus-4-5" = { limit.context = 200000; };
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
};
|
2026-04-01 14:10:41 +02:00
|
|
|
|
|
|
|
|
extraPlugins = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [];
|
|
|
|
|
description = ''
|
|
|
|
|
Additional opencode plugins to add to the plugin list.
|
|
|
|
|
Each entry is a path or package name passed to opencode's plugin array.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2026-03-30 19:04:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
programs.opencode = {
|
|
|
|
|
enable = true;
|
|
|
|
|
enableMcpIntegration = true;
|
|
|
|
|
settings = mkMerge [
|
|
|
|
|
{
|
|
|
|
|
theme = "opencode";
|
2026-04-09 13:58:45 +02:00
|
|
|
plugin = ["oh-my-openagent"] ++ cfg.extraPlugins;
|
2026-03-30 19:04:24 +02:00
|
|
|
formatter = {
|
|
|
|
|
alejandra = {
|
|
|
|
|
command = ["alejandra" "-q" "-"];
|
|
|
|
|
extensions = [".nix"];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
cfg.extraSettings
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
home.file.".config/opencode/oh-my-opencode.json".text = builtins.toJSON (
|
|
|
|
|
recursiveUpdate
|
|
|
|
|
{
|
|
|
|
|
"$schema" = "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json";
|
|
|
|
|
google_auth = false;
|
|
|
|
|
disabled_mcps = ["context7" "websearch"];
|
|
|
|
|
}
|
|
|
|
|
cfg.ohMyOpencodeSettings
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
}
|