mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-26 01:51:37 +00:00
mods: add a mods module (#6339)
This commit is contained in:
parent
ce9cb2496c
commit
744f749dd6
8 changed files with 126 additions and 0 deletions
|
@ -685,4 +685,10 @@
|
||||||
github = "3ulalia";
|
github = "3ulalia";
|
||||||
githubId = "179992797";
|
githubId = "179992797";
|
||||||
};
|
};
|
||||||
|
ipsavitsky = {
|
||||||
|
name = "Ilya Savitsky";
|
||||||
|
email = "ipsavitsky234@gmail.com";
|
||||||
|
github = "ipsavitsky";
|
||||||
|
githubId = 33558632;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2118,6 +2118,17 @@ in {
|
||||||
systemd service to ensure its execution.
|
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).
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,7 @@ let
|
||||||
./programs/mercurial.nix
|
./programs/mercurial.nix
|
||||||
./programs/micro.nix
|
./programs/micro.nix
|
||||||
./programs/mise.nix
|
./programs/mise.nix
|
||||||
|
./programs/mods.nix
|
||||||
./programs/mpv.nix
|
./programs/mpv.nix
|
||||||
./programs/mr.nix
|
./programs/mr.nix
|
||||||
./programs/msmtp.nix
|
./programs/msmtp.nix
|
||||||
|
|
77
modules/programs/mods.nix
Normal file
77
modules/programs/mods.nix
Normal 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
|
||||||
|
'');
|
||||||
|
};
|
||||||
|
}
|
|
@ -249,6 +249,7 @@ in import nmtSrc {
|
||||||
./modules/programs/mbsync
|
./modules/programs/mbsync
|
||||||
./modules/programs/micro
|
./modules/programs/micro
|
||||||
./modules/programs/mise
|
./modules/programs/mise
|
||||||
|
./modules/programs/mods
|
||||||
./modules/programs/mpv
|
./modules/programs/mpv
|
||||||
./modules/programs/mu
|
./modules/programs/mu
|
||||||
./modules/programs/mujmap
|
./modules/programs/mujmap
|
||||||
|
|
22
tests/modules/programs/mods/basic-configuration.nix
Normal file
22
tests/modules/programs/mods/basic-configuration.nix
Normal 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}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
7
tests/modules/programs/mods/basic-configuration.yml
Normal file
7
tests/modules/programs/mods/basic-configuration.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
apis:
|
||||||
|
ollama:
|
||||||
|
base-url: http://localhost:11434/api
|
||||||
|
models:
|
||||||
|
llama3.2:
|
||||||
|
max-input-chars: 650000
|
||||||
|
default-model: llama3.2
|
1
tests/modules/programs/mods/default.nix
Normal file
1
tests/modules/programs/mods/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ mods-basic-configuration = ./basic-configuration.nix; }
|
Loading…
Add table
Reference in a new issue