1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00
This commit is contained in:
Ilya Savitsky 2025-03-30 20:41:13 +01:00 committed by GitHub
commit bca1983a28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 60 additions and 0 deletions

View file

@ -355,6 +355,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

View 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;
}]);
}