2024-10-06 15:25:05 -05:00
|
|
|
{flake, ...}: let
|
|
|
|
inherit (flake.config.people) user0;
|
|
|
|
inherit (flake.config.people.user.${user0}) domain;
|
|
|
|
inherit (flake.config.system.device) server wildcard;
|
|
|
|
inherit (flake.config.service.instance.ollama) paths ports subdomain name ssl;
|
|
|
|
localhost = wildcard.ip.address0;
|
|
|
|
host = "${subdomain}.${domain.url0}";
|
|
|
|
in {
|
|
|
|
services = {
|
|
|
|
ollama = {
|
|
|
|
acceleration = false;
|
|
|
|
enable = true;
|
|
|
|
group = name;
|
|
|
|
host = "http://${localhost}";
|
|
|
|
port = ports.port1;
|
|
|
|
user = name;
|
|
|
|
};
|
|
|
|
|
|
|
|
open-webui = {
|
|
|
|
enable = true;
|
|
|
|
host = localhost;
|
|
|
|
port = ports.port0;
|
|
|
|
environment = {
|
|
|
|
ENABLE_OLLAMA_API = "True";
|
|
|
|
ANONYMIZED_TELEMETRY = "False";
|
|
|
|
DO_NOT_TRACK = "True";
|
|
|
|
SCARF_NO_ANALYTICS = "True";
|
|
|
|
OLLAMA_BASE_URL = "http://${localhost}:${toString ports.port1}";
|
|
|
|
WEBUI_AUTH = "True";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-07 14:28:40 -05:00
|
|
|
# caddy = {
|
|
|
|
# virtualHosts = {
|
|
|
|
# ${host} = {
|
|
|
|
# extraConfig = ''
|
|
|
|
# reverse_proxy ${localhost}:${toString ports.port0}
|
|
|
|
|
|
|
|
# tls ${ssl.cert} ${ssl.key}
|
|
|
|
# '';
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
# };
|
2024-10-06 15:25:05 -05:00
|
|
|
|
2024-10-07 14:28:40 -05:00
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts.${host} = {
|
|
|
|
enableSSL = true;
|
|
|
|
sslCertificate = ssl.cert;
|
|
|
|
sslCertificateKey = ssl.key;
|
|
|
|
listen = [
|
|
|
|
{
|
|
|
|
addr = "0.0.0.0";
|
|
|
|
port = 4443; # Use your desired port number
|
|
|
|
ssl = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://${localhost}:${toString ports.port0}";
|
|
|
|
extraConfig = ''
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
2024-10-06 15:25:05 -05:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fileSystems."/var/lib/${name}" = {
|
|
|
|
device = paths.path0;
|
|
|
|
fsType = "none";
|
|
|
|
options = ["bind"];
|
|
|
|
depends = [server.storage0.mount];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.tmpfiles.rules = ["Z ${paths.path0} 0755 ${name} ${name} -"];
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
ports.port0
|
|
|
|
ports.port1
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|