2024-04-17 17:01:45 +01:00
|
|
|
{ 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 = {
|
2024-04-28 01:29:48 +01:00
|
|
|
systemPackages = [ ollamaPkg pkgs.aichat ];
|
2024-05-14 17:09:45 +01:00
|
|
|
# variables = {
|
|
|
|
# OLLAMA_ORIGINS = "*";
|
|
|
|
# };
|
2024-03-14 11:55:56 +00:00
|
|
|
};
|
|
|
|
|
2024-05-14 17:09:45 +01:00
|
|
|
# services.ollama = {
|
|
|
|
# inherit listenAddress;
|
2024-03-14 11:55:56 +00:00
|
|
|
|
2024-05-14 17:09:45 +01:00
|
|
|
# enable = true;
|
|
|
|
# acceleration = "cuda";
|
|
|
|
# package = ollamaPkg;
|
|
|
|
# };
|
2024-03-14 11:55:56 +00:00
|
|
|
|
|
|
|
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 = ''
|
2024-04-02 22:56:17 +01:00
|
|
|
proxy_buffering off;
|
2024-02-21 11:33:54 +00:00
|
|
|
proxy_read_timeout 600s;
|
2024-05-14 17:09:45 +01:00
|
|
|
proxy_set_header Host localhost:${toString ollamaPort};
|
2024-02-21 11:33:54 +00:00
|
|
|
'';
|
2023-11-16 12:25:58 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualisation.oci-containers = {
|
|
|
|
containers = {
|
2024-05-14 17:09:45 +01:00
|
|
|
ollama = {
|
|
|
|
image = "ollama/ollama:latest";
|
|
|
|
autoStart = true;
|
|
|
|
extraOptions = [
|
|
|
|
"--pull=always"
|
|
|
|
"--gpus=all"
|
|
|
|
];
|
|
|
|
environment = {
|
|
|
|
OLLAMA_ORIGINS = "*";
|
|
|
|
};
|
|
|
|
volumes = [
|
|
|
|
"/ollama:/root/.ollama"
|
|
|
|
];
|
|
|
|
ports = [
|
|
|
|
"${listenAddress}:${toString ollamaPort}"
|
|
|
|
"172.17.0.1:${toString ollamaPort}:${toString ollamaPort}"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
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-04-28 01:29:48 +01:00
|
|
|
OLLAMA_BASE_URL = "https://${backendDomain}";
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|