2025-06-04 19:08:12 +02:00
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
with lib; let
|
2025-09-03 11:45:12 +02:00
|
|
|
cfg = config.home.dev.ai.ollama;
|
2025-06-04 19:08:12 +02:00
|
|
|
in {
|
2025-09-03 11:45:12 +02:00
|
|
|
options.home.dev.ai.ollama = {
|
2025-06-04 19:08:12 +02:00
|
|
|
enable = mkEnableOption "Enables Ollama";
|
|
|
|
|
gpu = mkOption {
|
2025-09-03 11:45:12 +02:00
|
|
|
type = types.nullOr (types.enum [false "rocm" "cuda"]);
|
|
|
|
|
example = "rocm";
|
|
|
|
|
default = null;
|
2025-06-04 19:08:12 +02:00
|
|
|
description = "Which type of GPU should be used for hardware acceleration";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-16 15:29:21 +01:00
|
|
|
config = {
|
|
|
|
|
services.ollama = mkIf cfg.enable {
|
|
|
|
|
inherit (cfg) enable;
|
|
|
|
|
acceleration = cfg.gpu;
|
|
|
|
|
host = "0.0.0.0";
|
|
|
|
|
environmentVariables = {
|
|
|
|
|
OLLAMA_CONTEXT_LENGTH = "8192";
|
|
|
|
|
OLLAMA_MAX_LOADED_MODELS = "1";
|
|
|
|
|
OLLAMA_KEEP_ALIVE = "10m";
|
|
|
|
|
};
|
2025-06-04 19:08:12 +02:00
|
|
|
};
|
2025-11-16 15:29:21 +01:00
|
|
|
home.sessionVariables.OLLAMA_API_BASE = "http://${config.services.ollama.host}:11434/";
|
2025-06-04 19:08:12 +02:00
|
|
|
};
|
|
|
|
|
}
|