2024-03-04 00:34:39 +03:00
|
|
|
{ pkgs, lib, ... }: {
|
2024-05-04 23:15:57 +03:00
|
|
|
# Add Ollama CLI app.
|
2024-03-04 00:34:39 +03:00
|
|
|
environment.systemPackages = with pkgs; [ ollama ];
|
2024-05-04 23:15:57 +03:00
|
|
|
|
|
|
|
# Enable Ollama server.
|
2024-03-04 00:34:39 +03:00
|
|
|
systemd.services.ollama = {
|
|
|
|
description = "Ollama LLM server.";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "NetworkManager-wait-online.service" ];
|
|
|
|
after = [ "NetworkManager-wait-online.service" ];
|
|
|
|
serviceConfig.Type = "simple";
|
|
|
|
script = ''
|
|
|
|
HOME=/root ${lib.getExe pkgs.ollama} serve
|
|
|
|
'';
|
|
|
|
};
|
2024-05-04 23:15:57 +03:00
|
|
|
|
|
|
|
# Download Ollama models.
|
2024-03-04 00:34:39 +03:00
|
|
|
systemd.services.ollamamodel = {
|
|
|
|
description = "Ollama LLM model.";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "ollama.service" ];
|
|
|
|
after = [ "ollama.service" ];
|
|
|
|
serviceConfig.Type = "simple";
|
|
|
|
script = ''
|
|
|
|
sleep 5
|
|
|
|
${lib.getExe pkgs.ollama} pull mistral
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|