2026-09-25 07:43:36 +02:00
|
|
|
# OpenCode 2 (TUI) configuration.
|
|
|
|
|
#
|
|
|
|
|
# v2 (pkgs.llm-agents.opencode2) reads ~/.config/opencode/opencode.json and
|
|
|
|
|
# normalizes the v1 config format internally: provider/permission/formatter
|
|
|
|
|
# keys written below are migrated on load, so the v1-style schema stays valid.
|
|
|
|
|
#
|
|
|
|
|
# TUI preferences live in cli.json, which v2 owns at runtime:
|
|
|
|
|
# - do NOT manage cli.json here (home-manager symlinks would break v2's
|
|
|
|
|
# runtime writes), and
|
|
|
|
|
# - do NOT set programs.opencode.tui (tui.json is a legacy source that v2
|
|
|
|
|
# re-imports into cli.json on every start, clobbering runtime prefs).
|
|
|
|
|
#
|
|
|
|
|
# The m3ta-nixpkgs `coding.opencode` wrapper is intentionally NOT used: it is
|
|
|
|
|
# v1-only (hardcodes the oh-my-openagent plugin and oh-my-openagent.json).
|
|
|
|
|
{pkgs, ...}: {
|
|
|
|
|
programs.opencode = {
|
2026-05-02 09:08:40 +02:00
|
|
|
enable = true;
|
2026-09-25 07:43:36 +02:00
|
|
|
enableMcpIntegration = true;
|
|
|
|
|
package = pkgs.llm-agents.opencode2;
|
2026-05-02 09:08:40 +02:00
|
|
|
|
2026-09-25 07:43:36 +02:00
|
|
|
settings = {
|
|
|
|
|
formatter = {
|
|
|
|
|
alejandra = {
|
|
|
|
|
command = ["alejandra" "-q" "-"];
|
|
|
|
|
extensions = [".nix"];
|
|
|
|
|
};
|
2026-05-02 09:08:40 +02:00
|
|
|
};
|
|
|
|
|
|
2026-09-25 07:43:36 +02:00
|
|
|
# Security: permission hardening for OpenCode
|
|
|
|
|
# Last matching rule wins. Glob patterns: * = any chars, ? = single char.
|
|
|
|
|
# ~ and $HOME are expanded to the user's home directory.
|
|
|
|
|
# external_directory gates paths outside the working directory.
|
|
|
|
|
permission = {
|
|
|
|
|
# External directory access: ask by default, allow safe paths
|
|
|
|
|
"external_directory" = {
|
|
|
|
|
"*" = "ask";
|
|
|
|
|
"/nix/store/**" = "allow";
|
|
|
|
|
"/tmp/**" = "allow";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Read access: allow by default, deny sensitive paths
|
|
|
|
|
"read" = {
|
|
|
|
|
"*" = "allow";
|
|
|
|
|
"~/.ssh/**" = "deny";
|
|
|
|
|
"~/.gnupg/**" = "deny";
|
|
|
|
|
"~/.aws/**" = "deny";
|
|
|
|
|
"~/.kube/**" = "deny";
|
|
|
|
|
"~/.config/gh/**" = "deny";
|
|
|
|
|
"~/.config/gcloud/**" = "deny";
|
|
|
|
|
"~/.config/op/**" = "deny";
|
|
|
|
|
"~/.config/sops/**" = "deny";
|
|
|
|
|
"/run/agenix/**" = "deny";
|
|
|
|
|
"~/.pi/agent/auth.json" = "deny";
|
|
|
|
|
"~/.pi/agent/sessions/**" = "deny";
|
|
|
|
|
"*.env" = "deny";
|
|
|
|
|
"*.env.*" = "deny";
|
|
|
|
|
"*.pem" = "deny";
|
|
|
|
|
"*.key" = "deny";
|
|
|
|
|
"*.p12" = "deny";
|
|
|
|
|
"*.pfx" = "deny";
|
|
|
|
|
"*id_rsa*" = "deny";
|
|
|
|
|
"*id_ed25519*" = "deny";
|
|
|
|
|
"*id_ecdsa*" = "deny";
|
|
|
|
|
"*.example.env" = "allow";
|
|
|
|
|
"*.sample.env" = "allow";
|
|
|
|
|
"*.test.env" = "allow";
|
|
|
|
|
".env.example" = "allow";
|
|
|
|
|
".env.sample" = "allow";
|
|
|
|
|
".env.test" = "allow";
|
|
|
|
|
"~/.ssh/*.pub" = "allow";
|
|
|
|
|
"*.pub" = "allow";
|
|
|
|
|
"*.csr" = "allow";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Edit access: ask by default, deny sensitive paths
|
|
|
|
|
"edit" = {
|
|
|
|
|
"*" = "ask";
|
|
|
|
|
"~/.ssh/**" = "deny";
|
|
|
|
|
"~/.gnupg/**" = "deny";
|
|
|
|
|
"~/.aws/**" = "deny";
|
|
|
|
|
"~/.kube/**" = "deny";
|
|
|
|
|
"~/.config/gh/**" = "deny";
|
|
|
|
|
"~/.config/gcloud/**" = "deny";
|
|
|
|
|
"~/.config/op/**" = "deny";
|
|
|
|
|
"~/.config/sops/**" = "deny";
|
|
|
|
|
"/run/agenix/**" = "deny";
|
|
|
|
|
"~/.pi/agent/auth.json" = "deny";
|
|
|
|
|
"~/.pi/agent/sessions/**" = "deny";
|
|
|
|
|
"*.env" = "deny";
|
|
|
|
|
"*.env.*" = "deny";
|
|
|
|
|
"*.pem" = "deny";
|
|
|
|
|
"*.key" = "deny";
|
|
|
|
|
"*.p12" = "deny";
|
|
|
|
|
"*.pfx" = "deny";
|
|
|
|
|
"*id_rsa*" = "deny";
|
|
|
|
|
"*id_ed25519*" = "deny";
|
|
|
|
|
"*id_ecdsa*" = "deny";
|
|
|
|
|
"~/.ssh/*.pub" = "allow";
|
|
|
|
|
"*.pub" = "allow";
|
|
|
|
|
"*.csr" = "allow";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Glob patterns: same rules as read for file matching
|
|
|
|
|
"glob" = {
|
|
|
|
|
"*" = "allow";
|
|
|
|
|
"~/.ssh/**" = "deny";
|
|
|
|
|
"~/.gnupg/**" = "deny";
|
|
|
|
|
"/run/agenix/**" = "deny";
|
|
|
|
|
"*.env" = "deny";
|
|
|
|
|
"*.env.*" = "deny";
|
|
|
|
|
"*.pem" = "deny";
|
|
|
|
|
"*.key" = "deny";
|
|
|
|
|
"*.p12" = "deny";
|
|
|
|
|
"*.pfx" = "deny";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Grep: allow search, but deny searching for secrets
|
|
|
|
|
"grep" = {
|
|
|
|
|
"*" = "allow";
|
|
|
|
|
"~/.ssh/**" = "deny";
|
|
|
|
|
"~/.gnupg/**" = "deny";
|
|
|
|
|
"/run/agenix/**" = "deny";
|
|
|
|
|
"*PASSWORD*" = "ask";
|
|
|
|
|
"*SECRET*" = "ask";
|
|
|
|
|
"*API_KEY*" = "ask";
|
|
|
|
|
"*PRIVATE_KEY*" = "ask";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Bash: ask by default, deny dangerous and env-leak commands
|
|
|
|
|
"bash" = {
|
|
|
|
|
"*" = "ask";
|
|
|
|
|
"git status*" = "allow";
|
|
|
|
|
"git diff*" = "allow";
|
|
|
|
|
"git log*" = "allow";
|
|
|
|
|
"git branch*" = "allow";
|
|
|
|
|
"git show*" = "allow";
|
|
|
|
|
"git remote*" = "allow";
|
|
|
|
|
"nix --version" = "allow";
|
|
|
|
|
"nix eval*" = "allow";
|
|
|
|
|
"nix build*" = "allow";
|
|
|
|
|
"nix develop*" = "allow";
|
|
|
|
|
"nix shell*" = "allow";
|
|
|
|
|
"nix search*" = "allow";
|
|
|
|
|
"alejandra*" = "allow";
|
|
|
|
|
"git add*" = "allow";
|
|
|
|
|
"git commit*" = "allow";
|
|
|
|
|
"git push*" = "ask";
|
|
|
|
|
"git pull*" = "allow";
|
|
|
|
|
"rm *" = "ask";
|
|
|
|
|
"rm -rf *" = "deny";
|
|
|
|
|
"sudo *" = "ask";
|
|
|
|
|
"env" = "deny";
|
|
|
|
|
"printenv" = "deny";
|
|
|
|
|
"cat /proc/*/environ" = "deny";
|
|
|
|
|
"gpg *--export-secret*" = "deny";
|
|
|
|
|
"ssh-add -D" = "deny";
|
|
|
|
|
"docker run --privileged*" = "deny";
|
|
|
|
|
"curl *| *sh" = "deny";
|
|
|
|
|
"wget *| *sh" = "deny";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Web fetch: allow by default
|
|
|
|
|
"webfetch" = "allow";
|
|
|
|
|
|
|
|
|
|
# Doom loop guard
|
|
|
|
|
"doom_loop" = "ask";
|
2026-05-02 09:08:40 +02:00
|
|
|
};
|
|
|
|
|
|
2026-09-25 07:43:36 +02:00
|
|
|
# AZ-Gruppe LiteLLM endpoint + available models
|
|
|
|
|
provider = {
|
|
|
|
|
litellm = {
|
|
|
|
|
npm = "@ai-sdk/openai-compatible";
|
|
|
|
|
name = "LiteLLM (AZ-Gruppe)";
|
|
|
|
|
options.baseURL = "https://llm.az-gruppe.com/v1";
|
|
|
|
|
models = {
|
|
|
|
|
"gpt-5.2" = {
|
|
|
|
|
name = "GPT-5.2";
|
|
|
|
|
limit = {
|
|
|
|
|
context = 400000;
|
|
|
|
|
output = 128000;
|
2026-05-02 09:08:40 +02:00
|
|
|
};
|
|
|
|
|
};
|
2026-09-25 07:43:36 +02:00
|
|
|
"gpt-5.6-sol" = {
|
|
|
|
|
name = "GPT-5.6 Sol";
|
|
|
|
|
limit = {
|
|
|
|
|
context = 400000;
|
|
|
|
|
output = 128000;
|
2026-05-02 09:08:40 +02:00
|
|
|
};
|
2026-08-03 11:49:56 +02:00
|
|
|
};
|
2026-09-25 07:43:36 +02:00
|
|
|
"gpt-5.3-codex" = {
|
|
|
|
|
name = "GPT-5.3 Codex";
|
|
|
|
|
limit = {
|
|
|
|
|
context = 400000;
|
|
|
|
|
output = 128000;
|
2026-05-02 09:08:40 +02:00
|
|
|
};
|
|
|
|
|
};
|
2026-09-25 07:43:36 +02:00
|
|
|
"claude-haiku-4-5" = {
|
|
|
|
|
name = "Claude Haiku 4.5";
|
|
|
|
|
options = {
|
|
|
|
|
thinking = {
|
|
|
|
|
type = "enabled";
|
|
|
|
|
budget_tokens = 16000;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
limit = {
|
|
|
|
|
context = 200000;
|
|
|
|
|
output = 64000;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
"claude-sonnet-5" = {
|
|
|
|
|
name = "Claude Sonnet 5";
|
|
|
|
|
options = {
|
|
|
|
|
thinking = {
|
|
|
|
|
type = "adaptive";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
limit = {
|
|
|
|
|
context = 200000;
|
|
|
|
|
output = 64000;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
"claude-opus-4-8" = {
|
|
|
|
|
name = "Claude Opus 4.8";
|
|
|
|
|
options = {
|
|
|
|
|
thinking = {
|
|
|
|
|
type = "adaptive";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
limit = {
|
|
|
|
|
context = 200000;
|
|
|
|
|
output = 128000;
|
|
|
|
|
};
|
2026-05-02 09:08:40 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|