nixos/hosts/architect/llm.nix

79 lines
1.5 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
2023-11-16 12:25:58 +00:00
let
2024-03-14 11:55:56 +00:00
frontendDomain = "pino.giugl.io";
backendDomain = "ollama.giugl.io";
2024-02-21 11:33:54 +00:00
frontendPort = 3030;
2024-03-14 11:55:56 +00:00
ollamaPort = 11434;
listenAddress = "127.0.0.1:${toString ollamaPort}";
ollamaPkg = pkgs.unstablePkgs.ollama;
2023-11-16 12:25:58 +00:00
in
{
2024-03-14 11:55:56 +00:00
environment = {
systemPackages = [ ollamaPkg ];
variables = {
OLLAMA_ORIGINS = "*";
};
};
services.ollama = {
inherit listenAddress;
enable = true;
acceleration = "cuda";
package = ollamaPkg;
};
architect.vhost.${frontendDomain} = {
2023-11-16 12:25:58 +00:00
dnsInterfaces = [ "tailscale" ];
locations."/" = {
2024-03-14 11:55:56 +00:00
host = "127.0.0.1";
2023-11-16 12:25:58 +00:00
port = frontendPort;
allowLan = true;
2024-02-21 11:33:54 +00:00
allowWAN = true;
extraConfig = ''
proxy_read_timeout 600s;
'';
};
};
2024-03-14 11:55:56 +00:00
architect.vhost.${backendDomain} = {
2024-02-21 11:33:54 +00:00
dnsInterfaces = [ "tailscale" ];
locations."/" = {
2024-03-14 11:55:56 +00:00
host = "127.0.0.1";
2024-02-21 11:33:54 +00:00
port = 11434;
allowLan = true;
allowWAN = true;
extraConfig = ''
proxy_read_timeout 600s;
'';
2023-11-16 12:25:58 +00:00
};
};
virtualisation.oci-containers = {
containers = {
2024-02-21 11:33:54 +00:00
ollama-webui = {
image = "ghcr.io/open-webui/open-webui:main";
2023-11-16 12:25:58 +00:00
autoStart = true;
ports = [
2024-03-14 11:55:56 +00:00
"127.0.0.1:${toString frontendPort}:8080"
2023-11-16 12:25:58 +00:00
];
2024-02-21 11:33:54 +00:00
environment = {
2024-03-14 11:55:56 +00:00
OLLAMA_API_BASE_URL = "https://${backendDomain}/api";
2024-02-21 11:33:54 +00:00
};
extraOptions = [
"--pull=always"
];
volumes = [
"/var/lib/ollama-webui:/app/backend/data"
2023-11-16 12:25:58 +00:00
];
2024-02-21 11:33:54 +00:00
};
2023-11-16 12:25:58 +00:00
};
};
}