1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-24 09:06:17 +00:00

mods: add a mods module (#6339)

This commit is contained in:
Ilya Savitsky 2025-03-10 04:05:08 +00:00 committed by GitHub
parent ce9cb2496c
commit 744f749dd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 126 additions and 0 deletions

View file

@ -685,4 +685,10 @@
github = "3ulalia";
githubId = "179992797";
};
ipsavitsky = {
name = "Ilya Savitsky";
email = "ipsavitsky234@gmail.com";
github = "ipsavitsky";
githubId = 33558632;
};
}

View file

@ -2118,6 +2118,17 @@ in {
systemd service to ensure its execution.
'';
}
{
time = "2025-01-26T16:40:00+00:00";
message = ''
A new module is available: 'programs.mods'
mods is a command line AI tool that is highly configurable and allows
querying AI models hosted locally or by other services (OpenAI,
Cohere, Groq).
'';
}
];
};
}

View file

@ -169,6 +169,7 @@ let
./programs/mercurial.nix
./programs/micro.nix
./programs/mise.nix
./programs/mods.nix
./programs/mpv.nix
./programs/mr.nix
./programs/msmtp.nix

77
modules/programs/mods.nix Normal file
View file

@ -0,0 +1,77 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.mods;
yamlFormat = pkgs.formats.yaml { };
in {
meta.maintainers = [ hm.maintainers.ipsavitsky ];
options.programs.mods = {
enable = mkEnableOption "mods";
package = mkOption {
type = types.package;
default = pkgs.mods;
defaultText = literalExpression "pkgs.mods";
description = "The mods package to install";
};
settings = 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.initExtra = 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
'');
};
}

View file

@ -249,6 +249,7 @@ in import nmtSrc {
./modules/programs/mbsync
./modules/programs/micro
./modules/programs/mise
./modules/programs/mods
./modules/programs/mpv
./modules/programs/mu
./modules/programs/mujmap

View file

@ -0,0 +1,22 @@
{ config, pkgs, ... }: {
config = {
programs.mods = {
enable = true;
package = pkgs.writeScriptBin "dummy-mods" "";
settings = {
default-model = "llama3.2";
apis = {
ollama = {
base-url = "http://localhost:11434/api";
models = { "llama3.2" = { max-input-chars = 650000; }; };
};
};
};
};
nmt.script = ''
assertFileExists home-files/.config/mods/mods.yml
assertFileContent home-files/.config/mods/mods.yml \
${./basic-configuration.yml}
'';
};
}

View file

@ -0,0 +1,7 @@
apis:
ollama:
base-url: http://localhost:11434/api
models:
llama3.2:
max-input-chars: 650000
default-model: llama3.2

View file

@ -0,0 +1 @@
{ mods-basic-configuration = ./basic-configuration.nix; }