Files
home-manager/tests/modules/programs/opencode/mixed-content.nix
Thierry Delafontaine 081234b704 opencode: support directory-based configuration for commands, agents, and themes
The `commands`, `agents`, and `themes` options now accept either an
attribute set (existing behavior) or a path to a directory containing
multiple files. When a directory path is provided, it is symlinked to
the appropriate `$XDG_CONFIG_HOME/opencode/` subdirectory.

This change aligns with the existing `skills` option implementation and
provides a more convenient way to manage multiple configuration files
without needing to define each one individually in Nix.
2026-01-08 16:32:29 -05:00

80 lines
2.4 KiB
Nix

{
programs.opencode = {
enable = true;
commands = {
inline-command = ''
# Inline Command
This command is defined inline.
'';
path-command = ./test-command.md;
};
agents = {
inline-agent = ''
# Inline Agent
This agent is defined inline.
'';
path-agent = ./test-agent.md;
};
skills = {
inline-skill = ''
---
name: inline-skill
description: An inline skill definition
---
## What I do
This skill is defined inline.
'';
path-skill = ./git-release-SKILL.md;
dir-skill = ./skill-dir/data-analysis;
};
themes = {
inline-theme = {
name = "inline-theme";
colors = {
primary = "#000000";
secondary = "#ffffff";
};
};
path-theme = ./my-theme.json;
};
};
nmt.script = ''
# Commands
assertFileExists home-files/.config/opencode/command/inline-command.md
assertFileExists home-files/.config/opencode/command/path-command.md
assertFileContent home-files/.config/opencode/command/path-command.md \
${./test-command.md}
# Agents
assertFileExists home-files/.config/opencode/agent/inline-agent.md
assertFileExists home-files/.config/opencode/agent/path-agent.md
assertFileContent home-files/.config/opencode/agent/path-agent.md \
${./test-agent.md}
# Skills
assertFileExists home-files/.config/opencode/skill/inline-skill/SKILL.md
assertFileExists home-files/.config/opencode/skill/path-skill/SKILL.md
assertFileExists home-files/.config/opencode/skill/dir-skill/SKILL.md
assertFileExists home-files/.config/opencode/skill/dir-skill/notes.txt
assertFileContent home-files/.config/opencode/skill/path-skill/SKILL.md \
${./git-release-SKILL.md}
assertFileContent home-files/.config/opencode/skill/dir-skill/SKILL.md \
${./skill-dir/data-analysis/SKILL.md}
# Themes
assertFileExists home-files/.config/opencode/themes/inline-theme.json
assertFileExists home-files/.config/opencode/themes/path-theme.json
assertFileContent home-files/.config/opencode/themes/path-theme.json \
${./my-theme.json}
# Verify inline-theme has the schema
assertFileContains home-files/.config/opencode/themes/inline-theme.json \
'"$schema": "https://opencode.ai/theme.json"'
'';
}