mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-16 10:05:13 -05:00
refactor: cleaned up nixos dir
This commit is contained in:
parent
89814be57c
commit
2000adb56a
77 changed files with 422 additions and 464 deletions
117
nixos/modules/services/ollama/default.nix
Executable file
117
nixos/modules/services/ollama/default.nix
Executable file
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (flake.config.machines.devices)
|
||||
desktop
|
||||
server
|
||||
;
|
||||
inherit (flake.config.services.instances)
|
||||
ollama
|
||||
web
|
||||
;
|
||||
service = ollama;
|
||||
localhost = web.localhost.address0;
|
||||
hostname = config.networking.hostName;
|
||||
host = "${service.subdomain}.${web.domains.url0}";
|
||||
|
||||
caddyLogic =
|
||||
if hostname == server.name then
|
||||
{
|
||||
caddy = {
|
||||
virtualHosts = {
|
||||
${host} = {
|
||||
extraConfig = ''
|
||||
reverse_proxy ${localhost}:${toString service.ports.port0}
|
||||
|
||||
tls ${service.ssl.cert} ${service.ssl.key}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
mountLogic =
|
||||
if hostname == server.name then
|
||||
{
|
||||
"/var/lib/${service.name}" = {
|
||||
device = service.paths.path0;
|
||||
fsType = "none";
|
||||
options = [
|
||||
"bind"
|
||||
];
|
||||
depends = [
|
||||
server.storage0.mount
|
||||
];
|
||||
};
|
||||
}
|
||||
else
|
||||
{ };
|
||||
in
|
||||
{
|
||||
services = {
|
||||
ollama =
|
||||
{
|
||||
enable = true;
|
||||
group = service.name;
|
||||
host = "http://${localhost}";
|
||||
user = service.name;
|
||||
}
|
||||
// (
|
||||
if hostname == desktop.name then
|
||||
{
|
||||
acceleration = "rocm";
|
||||
package = pkgs.ollama.override {
|
||||
config = {
|
||||
rocmSupport = true;
|
||||
cudaSupport = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
port = service.ports.port1;
|
||||
acceleration = false;
|
||||
models = service.paths.path1;
|
||||
}
|
||||
);
|
||||
open-webui = {
|
||||
enable = true;
|
||||
host = localhost;
|
||||
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 service.ports.port1}";
|
||||
WEBUI_AUTH = "True";
|
||||
};
|
||||
};
|
||||
} // caddyLogic;
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
(
|
||||
if hostname == desktop.name then
|
||||
"Z ${service.paths.path1} 0777 ${service.name} ${service.name} -"
|
||||
else
|
||||
"Z ${service.paths.path0} 0755 ${service.name} ${service.name} -"
|
||||
)
|
||||
];
|
||||
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [
|
||||
# 8080
|
||||
service.ports.port0
|
||||
service.ports.port1
|
||||
];
|
||||
};
|
||||
};
|
||||
fileSystems = mountLogic;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue