dotfiles/nixos/modules/ollama.nix

65 lines
1.3 KiB
Nix
Raw Normal View History

2025-01-20 23:33:35 -06:00
{
flake,
pkgs,
...
}:
let
inherit (flake.config.services.instances)
2025-01-08 19:06:14 -06:00
ollama
web
;
2024-10-19 18:22:29 -05:00
service = ollama;
localhost = web.localhost.address0;
2025-01-20 23:33:35 -06:00
in
{
2024-10-06 15:25:05 -05:00
services = {
ollama = {
2025-02-01 23:30:06 -06:00
acceleration = "rocm";
package = pkgs.ollama.override {
config = {
rocmSupport = true;
cudaSupport = false;
};
};
2024-10-06 15:25:05 -05:00
enable = true;
2024-10-19 18:22:29 -05:00
group = service.name;
2024-10-06 15:25:05 -05:00
host = "http://${localhost}";
2025-01-20 23:33:35 -06:00
# models = service.paths.path1;
2024-10-19 18:22:29 -05:00
user = service.name;
2024-10-06 15:25:05 -05:00
};
2025-01-20 23:33:35 -06:00
# llama-cpp = {
# enable = true;
# port = 8080;
# host = localhost;
# model = "/models/qwen2.5-coder-32b-instruct-q8_0-00004-of-00005.gguf";
# };
2024-10-06 15:25:05 -05:00
open-webui = {
enable = true;
host = localhost;
2024-10-19 18:22:29 -05:00
port = service.ports.port0;
2024-10-06 15:25:05 -05:00
environment = {
ENABLE_OLLAMA_API = "True";
ANONYMIZED_TELEMETRY = "False";
DO_NOT_TRACK = "True";
SCARF_NO_ANALYTICS = "True";
2024-10-19 18:22:29 -05:00
OLLAMA_BASE_URL = "http://${localhost}:${toString service.ports.port1}";
2024-10-06 15:25:05 -05:00
WEBUI_AUTH = "True";
};
};
};
2025-01-08 19:06:14 -06:00
systemd.tmpfiles.rules = [
"Z ${service.paths.path1} 0755 ${service.name} ${service.name} -"
];
2024-10-06 15:25:05 -05:00
networking = {
firewall = {
allowedTCPPorts = [
2025-01-20 23:33:35 -06:00
# 8080
2024-10-19 18:22:29 -05:00
service.ports.port0
service.ports.port1
2024-10-06 15:25:05 -05:00
];
};
};
}