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, config,
lib,
pkgsUnstable,
... ...
}: }:
let let
@ -9,40 +9,12 @@ let
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# Specify default model. services.ollama = {
environment.variables.OLLAMA_MODEL = cfg.primaryModel; enable = true;
host = "[::1]";
systemd.services = { loadModels = cfg.models;
# Enable Ollama server. package = pkgsUnstable.ollama;
ollama = { # acceleration = false;
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}
'';
};
}; };
}; };
} }

View file

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