nixcfg/modules/home/cli-apps/opencode/default.nix
Harald Hoyer d0c58a5c9d feat(opencode): configure formatters and provide them on PATH
Add formatter entries for nix, prettier (md/yaml/json/web), shell,
python, toml and lua, and install the matching tools via the opencode
home module so they are available wherever opencode runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:02:53 +02:00

56 lines
1.1 KiB
Nix

{
lib,
config,
pkgs,
inputs,
...
}:
let
inherit (lib) mkIf;
inherit (lib.metacfg) mkBoolOpt;
cfg = config.metacfg.cli-apps.opencode;
obsidianSkills =
lib.mapAttrs'
(
name: _:
lib.nameValuePair ".agents/skills/${name}" {
source = "${inputs.obsidian-skills}/skills/${name}";
recursive = true;
}
)
(
lib.filterAttrs (_: type: type == "directory") (builtins.readDir "${inputs.obsidian-skills}/skills")
);
in
{
options.metacfg.cli-apps.opencode = {
enable = mkBoolOpt true "Enable opencode config.";
};
config = mkIf cfg.enable {
# Formatters referenced by config/opencode/config.json; keep them on PATH for opencode.
home.packages = [
pkgs.nixfmt-rfc-style
pkgs.nodePackages.prettier
pkgs.shfmt
pkgs.ruff
pkgs.taplo
pkgs.stylua
];
xdg.configFile."opencode" = {
source = ../../../../config/opencode;
recursive = true;
};
home.file = {
".agents/skills" = {
source = ../../../../config/agents/skills;
recursive = true;
};
}
// obsidianSkills;
};
}