Files
nixos-config/services/ollama.nix
2026-04-20 14:28:12 +09:00

33 lines
912 B
Nix

{ config, pkgs, ... }:
{
systemd.services.my-ollama = {
description = "Custom Ollama-like Service";
# Ensure the service starts after the network is up
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
# Environment variables
environment = {
OLLAMA_KV_CACHE_TYPE = "q8_0";
OLLAMA_NUM_GPU = "1";
GGML_CUDA_ENABLE_UNIFIED_MEMORY = "1";
OLLAMA_KEEP_ALIVE = "-1";
OLLAMA_MODELS = "/mnt/ssd1/ollama";
OLLAMA_NUM_PARALLEL = "4";
# Adding CUDA paths for NixOS
LD_LIBRARY_PATH = "/run/opengl-driver/lib:/run/cudatoolkit/lib";
};
serviceConfig = {
# Use the package reference so Nix finds the correct path
ExecStart = "/usr/bin/ollama serve";
# Recommended security/reliability settings
Restart = "always";
User = "root"; # Or a specific user if permissions allow
};
};
}