configs/appserver/server1/nixos/ollama.nix

31 lines
800 B
Nix
Raw Normal View History

2024-05-20 12:24:36 +02:00
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
ollama
];
systemd.services = {
ollama = {
description = "Server for local large language models";
after = ["network-online.target"];
wantedBy = ["multi-user.target"];
environment = {
HOME = "%S/ollama";
OLLAMA_HOST = "0.0.0.0";
OLLAMA_MODELS = "%S/ollama/models";
};
serviceConfig = {
Type = "simple";
User = "ollama";
Group = "ollama";
Restart = "always";
RestartSec = "3";
WorkingDirectory = "/var/lib/ollama";
StateDirectory = [ "ollama" ];
DynamicUser = true;
ExecStart = "${pkgs.ollama}/bin/ollama serve";
};
};
};
networking.firewall.allowedTCPPorts = [ 11434 ];
}