Files
infra/modules/nixos/services/ollama_init_custom_models.nix
Thierry Pouplier b54760f62b docs: initialize NixOS infrastructure with AI assistant
Creates PROJECT.md with vision and requirements.
Creates config.json with interactive workflow mode.
2026-01-01 01:36:58 -05:00

32 lines
1.2 KiB
Nix

systemd.services.init-ollama-model = {
description = "Initialize nemotron 3 with extra context in Ollama Docker";
after = [ "docker-ollama.service" ]; # Ensure it runs after your ollama container
wantedBy = [ "multi-user.target" ];
script = ''
# Wait for Ollama
while ! ${pkgs.curl}/bin/curl -s http://localhost:11434/api/tags > /dev/null; do
sleep 2
done
# Check if the model already exists in the persistent volume
if ! ${pkgs.docker}/bin/docker exec ollama ollama list | grep -q "nemotron-3-nano:30b-128k"; then
echo "nemotron-3-nano:30b-128k not found, creating..."
${pkgs.docker}/bin/docker exec ollama sh -c 'cat <<EOF > /root/.ollama/nemotron-3-nano:30b-128k.modelfile
FROM nemotron-3-nano:30b
PARAMETER num_ctx 131072
PARAMETER num_predict 4096
PARAMETER repeat_penalty 1.1
EOF'
${pkgs.docker}/bin/docker exec ollama ollama create nemotron-3-nano:30b-128k -f /root/.ollama/nemotron-3-nano:30b-128k.modelfile
else
echo "nemotron-3-nano:30b-128k already exists, skipping creation."
fi
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
};