2024-10-06 15:25:05 -05:00
|
|
|
{flake, ...}: let
|
2024-10-19 18:22:29 -05:00
|
|
|
inherit (flake.config.system.device) server;
|
|
|
|
inherit (flake.config.service.instance) ollama web;
|
|
|
|
service = ollama;
|
|
|
|
localhost = web.localhost.address0;
|
|
|
|
host = "${service.subdomain}.${web.domains.url0}";
|
2024-10-06 15:25:05 -05:00
|
|
|
in {
|
|
|
|
services = {
|
|
|
|
ollama = {
|
|
|
|
acceleration = false;
|
|
|
|
enable = true;
|
2024-10-19 18:22:29 -05:00
|
|
|
group = service.name;
|
2024-10-06 15:25:05 -05:00
|
|
|
host = "http://${localhost}";
|
2024-10-19 18:22:29 -05:00
|
|
|
port = service.ports.port1;
|
|
|
|
user = service.name;
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
open-webui = {
|
|
|
|
enable = true;
|
|
|
|
host = localhost;
|
2024-10-19 18:22:29 -05:00
|
|
|
port = service.ports.port0;
|
2024-10-06 15:25:05 -05:00
|
|
|
environment = {
|
|
|
|
ENABLE_OLLAMA_API = "True";
|
|
|
|
ANONYMIZED_TELEMETRY = "False";
|
|
|
|
DO_NOT_TRACK = "True";
|
|
|
|
SCARF_NO_ANALYTICS = "True";
|
2024-10-19 18:22:29 -05:00
|
|
|
OLLAMA_BASE_URL = "http://${localhost}:${toString service.ports.port1}";
|
2024-10-06 15:25:05 -05:00
|
|
|
WEBUI_AUTH = "True";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-07 14:49:28 -05:00
|
|
|
caddy = {
|
|
|
|
virtualHosts = {
|
|
|
|
${host} = {
|
2024-10-07 14:28:40 -05:00
|
|
|
extraConfig = ''
|
2024-10-19 18:22:29 -05:00
|
|
|
reverse_proxy ${localhost}:${toString service.ports.port0}
|
2024-10-07 14:49:28 -05:00
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
2024-10-06 15:25:05 -05:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
|
|
device = service.paths.path0;
|
2024-10-06 15:25:05 -05:00
|
|
|
fsType = "none";
|
|
|
|
options = ["bind"];
|
|
|
|
depends = [server.storage0.mount];
|
|
|
|
};
|
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
systemd.tmpfiles.rules = ["Z ${service.paths.path0} 0755 ${service.name} ${service.name} -"];
|
2024-10-06 15:25:05 -05:00
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
2024-10-19 18:22:29 -05:00
|
|
|
service.ports.port0
|
|
|
|
service.ports.port1
|
2024-10-06 15:25:05 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|