1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-06 00:51:04 +01:00
home-manager/modules/programs/mods.nix
Austin Horstman 0b491b460f
treewide: remove with lib (#6735)
Continuation of `with lib;` cleanup.
2025-03-31 22:32:16 -05:00

72 lines
1.9 KiB
Nix

{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkOrder;
cfg = config.programs.mods;
yamlFormat = pkgs.formats.yaml { };
in {
meta.maintainers = [ lib.hm.maintainers.ipsavitsky ];
options.programs.mods = {
enable = lib.mkEnableOption "mods";
package = lib.mkPackageOption pkgs "mods" { };
settings = lib.mkOption {
type = yamlFormat.type;
default = { };
example = ''
{
default-model = "llama3.2";
apis = {
ollama = {
base-url = "http://localhost:11434/api";
models = {
"llama3.2" = {
max-input-chars = 650000;
};
};
};
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/mods/mods.yml`.
See <https://github.com/charmbracelet/mods/blob/main/config_template.yml> for the full
list of options.
'';
};
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };
enableZshIntegration =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
enableFishIntegration =
lib.hm.shell.mkFishIntegrationOption { inherit config; };
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."mods/mods.yml" = mkIf (cfg.settings != { }) {
source = yamlFormat.generate "mods.yml" cfg.settings;
};
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 ''
source <(${cfg.package}/bin/mods completion bash)
'');
programs.zsh.initContent = mkIf cfg.enableZshIntegration (mkOrder 200 ''
source <(${cfg.package}/bin/mods completion zsh)
'');
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
(mkOrder 200 ''
${cfg.package}/bin/mods completion fish | source
'');
};
}