opencode: init (#7320)
This commit is contained in:
parent
f117b383dd
commit
5a49fe448e
4 changed files with 78 additions and 0 deletions
53
modules/programs/opencode.nix
Normal file
53
modules/programs/opencode.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
literalExpression
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
mkPackageOption
|
||||
;
|
||||
|
||||
cfg = config.programs.opencode;
|
||||
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ delafthi ];
|
||||
|
||||
options.programs.opencode = {
|
||||
enable = mkEnableOption "opencode";
|
||||
|
||||
package = mkPackageOption pkgs "opencode" { nullable = true; };
|
||||
|
||||
settings = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
theme = "opencode";
|
||||
model = "anthropic/claude-sonnet-4-20250514";
|
||||
autoshare = false;
|
||||
autoupdate = true;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to {file}`$XDG_CONFIG_HOME/opencode/config.json`.
|
||||
See <https://opencode.ai/docs/config/> for the documentation.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."opencode/config.json" = mkIf (cfg.settings != { }) {
|
||||
source = jsonFormat.generate "config.json" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue