feat: refactored abstractions

This commit is contained in:
Nick 2024-10-19 18:22:29 -05:00
parent f3897c1e0c
commit 2e0ba5f89e
23 changed files with 324 additions and 310 deletions

View file

@ -1,31 +1,30 @@
{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}";
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}";
in {
services = {
ollama = {
acceleration = false;
enable = true;
group = name;
group = service.name;
host = "http://${localhost}";
port = ports.port1;
user = name;
port = service.ports.port1;
user = service.name;
};
open-webui = {
enable = true;
host = localhost;
port = ports.port0;
port = service.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}";
OLLAMA_BASE_URL = "http://${localhost}:${toString service.ports.port1}";
WEBUI_AUTH = "True";
};
};
@ -34,29 +33,29 @@ in {
virtualHosts = {
${host} = {
extraConfig = ''
reverse_proxy ${localhost}:${toString ports.port0}
reverse_proxy ${localhost}:${toString service.ports.port0}
tls ${ssl.cert} ${ssl.key}
tls ${service.ssl.cert} ${service.ssl.key}
'';
};
};
};
};
fileSystems."/var/lib/${name}" = {
device = paths.path0;
fileSystems."/var/lib/${service.name}" = {
device = service.paths.path0;
fsType = "none";
options = ["bind"];
depends = [server.storage0.mount];
};
systemd.tmpfiles.rules = ["Z ${paths.path0} 0755 ${name} ${name} -"];
systemd.tmpfiles.rules = ["Z ${service.paths.path0} 0755 ${service.name} ${service.name} -"];
networking = {
firewall = {
allowedTCPPorts = [
ports.port0
ports.port1
service.ports.port0
service.ports.port1
];
};
};