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";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config.services.ollama = mkIf cfg.enable {
|
|
|
|
|
inherit (cfg) enable;
|
2025-09-03 11:45:12 +02:00
|
|
|
acceleration = cfg.gpu;
|
2025-06-04 19:08:12 +02:00
|
|
|
environmentVariables = {
|
|
|
|
|
OLLAMA_CONTEXT_LENGTH = "8192";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|