Ollama: Use nixos module & switch to deepseek-r1.

This commit is contained in:
Dmitry Voronin 2025-01-22 17:10:29 +03:00
parent bd1b35d660
commit 74a14283f7
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
2 changed files with 10 additions and 37 deletions

View file

@ -1,7 +1,7 @@
{
pkgsUnstable,
lib,
config,
lib,
pkgsUnstable,
...
}:
let
@ -9,40 +9,12 @@ let
in
{
config = lib.mkIf cfg.enable {
# Specify default model.
environment.variables.OLLAMA_MODEL = cfg.primaryModel;
systemd.services = {
# Enable Ollama server.
ollama = {
description = "Ollama LLM server";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
};
script = ''
HOME=/root ${lib.getExe pkgsUnstable.ollama} serve
'';
};
# Download Ollama models.
ollama-pull = {
description = "Ollama LLM model";
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "simple";
after = [
"NetworkManager-wait-online.service"
"ollama.service"
];
wants = [
"NetworkManager-wait-online.service"
"ollama.service"
];
script = ''
sleep 5
HOME=/root ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models}
'';
};
services.ollama = {
enable = true;
host = "[::1]";
loadModels = cfg.models;
package = pkgsUnstable.ollama;
# acceleration = false;
};
};
}

View file

@ -13,8 +13,9 @@ in
default = [ cfg.primaryModel ];
type = with lib.types; listOf str;
};
# REF: https://ollama.com/library
primaryModel = lib.mkOption {
default = "llama3.2";
default = "deepseek-r1";
type = lib.types.str;
};
};