1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-01 06:31:04 +01:00
home-manager/modules/programs/aichat.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05:00

74 lines
2 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf;
cfg = config.programs.aichat;
settingsFormat = pkgs.formats.yaml { };
inherit (pkgs.stdenv.hostPlatform) isLinux isDarwin;
in
{
meta.maintainers = [
lib.maintainers.jaredmontoya
];
options.programs.aichat = {
enable = lib.mkEnableOption "aichat, an All-in-one LLM CLI tool";
package = lib.mkPackageOption pkgs "aichat" { nullable = true; };
settings = lib.mkOption {
inherit (settingsFormat) type;
default = { };
defaultText = lib.literalExpression "{ }";
example = lib.literalExpression ''
{
model = "ollama:mistral-small3.1:latest";
clients = [
{
type = "openai-compatible";
name = "ollama";
api_base = "http://localhost:11434/v1";
models = [
{
name = "mistral-small3.1:latest";
supports_function_calling = true;
supports_vision = true;
}
];
}
];
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/aichat/config.yaml`
on Linux or on Darwin if [](#opt-xdg.enable) is set, otherwise
{file}`~/Library/Application Support/aichat/config.yaml`.
See
<https://github.com/sigoden/aichat/blob/main/config.example.yaml>
for supported values.
'';
};
};
config = mkIf cfg.enable {
home.packages = mkIf (cfg.package != null) [ cfg.package ];
home.file."Library/Application Support/aichat/config.yaml" =
mkIf (cfg.settings != { } && (isDarwin && !config.xdg.enable))
{
source = settingsFormat.generate "aichat-config" cfg.settings;
};
xdg.configFile."aichat/config.yaml" = mkIf (cfg.settings != { } && (isLinux || config.xdg.enable)) {
source = settingsFormat.generate "aichat-config" cfg.settings;
};
};
}