mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
local-ai: init module
This commit is contained in:
parent
1efd250317
commit
4760d75c85
2 changed files with 60 additions and 0 deletions
|
@ -354,6 +354,7 @@ let
|
|||
./services/lieer.nix
|
||||
./services/linux-wallpaperengine.nix
|
||||
./services/listenbrainz-mpd.nix
|
||||
./services/local-ai.nix
|
||||
./services/lorri.nix
|
||||
./services/lxqt-policykit-agent.nix
|
||||
./services/macos-remap-keys
|
||||
|
|
59
modules/services/local-ai.nix
Normal file
59
modules/services/local-ai.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.local-ai;
|
||||
settingsPath = "local/config.yml";
|
||||
in {
|
||||
options.services.local-ai = {
|
||||
enable =
|
||||
mkEnableOption "LocalAI is the free, Open Source OpenAI alternative.";
|
||||
|
||||
extraArgs = lib.mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Extra arguments to pass to local-ai";
|
||||
};
|
||||
|
||||
package = mkPackageOption pkgs "local-ai" { };
|
||||
|
||||
port = mkOption {
|
||||
type = lib.types.port;
|
||||
default = 8080;
|
||||
description = "Port to set up local-ai with";
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
inherit (pkgs.formats.yaml { }) type;
|
||||
|
||||
description = ''
|
||||
Configuration written to {file}`$XDG_CONFIG_HOME/${settingsPath}`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [{
|
||||
home.packages = lib.mkIf cfg.openPackage (lib.singleton
|
||||
(pkgs.writeShellApplication {
|
||||
name = "${cfg.package.pname}-open";
|
||||
runtimeInputs = [ pkgs.xdg-utils ];
|
||||
text = "xdg-open localhost:${toString cfg.port}";
|
||||
}));
|
||||
|
||||
systemd.user.services.local-ai = {
|
||||
Service = {
|
||||
ExecStart = lib.escapeShellArgs ([
|
||||
(lib.getExe cfg.package)
|
||||
"--address"
|
||||
":${toString cfg.port}"
|
||||
"--debug"
|
||||
] ++ cfg.extraArgs);
|
||||
|
||||
RuntimeDirectory = "local-ai";
|
||||
WorkingDirectory = "%t/local-ai";
|
||||
};
|
||||
};
|
||||
|
||||
xdg.configFile.${settingsPath}.text = builtins.toJSON cfg.settings;
|
||||
}]);
|
||||
}
|
Loading…
Add table
Reference in a new issue