mirror of
https://github.com/nix-community/home-manager.git
synced 2026-12-06 04:40:17 +00:00
Add programs.opencode.cli for OpenCode 2's global cli.json, while retaining programs.opencode.tui for OpenCode 1. Support mutable CLI configuration through OPENCODE_CLI_CONFIG_CONTENT, leaving cli.json writable by OpenCode. Add validation against the configured package's CLI schema and warn when CLI or TUI settings do not match the package version.
34 lines
1.4 KiB
Nix
34 lines
1.4 KiB
Nix
{ config, lib, ... }:
|
|
{
|
|
imports = [ ./opencode-stubs.nix ];
|
|
|
|
programs.opencode = {
|
|
enable = true;
|
|
mutableSettings = true;
|
|
settings.permission.bash = {
|
|
"aa *" = lib.hm.dag.entryAfter [ "zz *" ] "allow";
|
|
"zz *" = "ask";
|
|
};
|
|
tui.theme = "system";
|
|
};
|
|
assertions = [
|
|
{
|
|
assertion = (config.home.sessionVariables ? OPENCODE_CONFIG);
|
|
message = "OpenCode must export a settings selector only for an enabled nonempty layer.";
|
|
}
|
|
{
|
|
assertion = (config.home.sessionVariables ? OPENCODE_TUI_CONFIG);
|
|
message = "OpenCode must export a TUI selector only for an enabled nonempty layer.";
|
|
}
|
|
];
|
|
nmt.script = ''
|
|
assertFileContent "home-files/.config/opencode/home-manager.json" ${./settings-ordered-permissions.json}
|
|
assertFileContent "home-files/.config/opencode/home-manager-tui.json" ${./read-only-layer-tui.json}
|
|
assertPathNotExists "home-files/.config/opencode/opencode.json"
|
|
assertPathNotExists "home-files/.config/opencode/tui.json"
|
|
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
|
assertFileContains home-path/etc/profile.d/hm-session-vars.sh 'export OPENCODE_CONFIG="${config.home.homeDirectory}/.config/opencode/home-manager.json"'
|
|
assertFileContains home-path/etc/profile.d/hm-session-vars.sh 'export OPENCODE_TUI_CONFIG="${config.home.homeDirectory}/.config/opencode/home-manager-tui.json"'
|
|
'';
|
|
}
|