ollama official service
This commit is contained in:
@@ -1,43 +1,51 @@
|
||||
{ config, pkgs, lib, system, user, host, allowed, secrets, ... }:
|
||||
{ pkgs, lib, host, nvidia, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
ollama
|
||||
];
|
||||
|
||||
services.ollama.environmentVariables = {
|
||||
OLLAMA_ORIGINS = "*";
|
||||
};
|
||||
# services.ollama.environmentVariables = {
|
||||
# OLLAMA_ORIGINS = "*";
|
||||
# };
|
||||
|
||||
systemd.services.ollama = {
|
||||
environment.OLLAMA_ORIGINS = "*";
|
||||
description = "Ollama Service";
|
||||
after = [ "network-online.target" "ollama-doesnt-respect-xdg-data-home.service" ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
# Environment = "\"XDG_DATA_HOME=/run/current-system/sw/share\"";
|
||||
ExecStart = "${pkgs.ollama}/bin/ollama serve";
|
||||
User = "ollama";
|
||||
Group = "ollama";
|
||||
Restart = "always";
|
||||
RestartSec = "3";
|
||||
# systemd.services.ollama = {
|
||||
# environment.OLLAMA_ORIGINS = "*";
|
||||
# description = "Ollama Service";
|
||||
# after = [ "network-online.target" "ollama-doesnt-respect-xdg-data-home.service" ];
|
||||
# serviceConfig = {
|
||||
# Type = "simple";
|
||||
# # Environment = "\"XDG_DATA_HOME=/run/current-system/sw/share\"";
|
||||
# ExecStart = "${pkgs.ollama}/bin/ollama serve";
|
||||
# User = "ollama";
|
||||
# Group = "ollama";
|
||||
# Restart = "always";
|
||||
# RestartSec = "3";
|
||||
# };
|
||||
# wantedBy = [ "default.target" ];
|
||||
# };
|
||||
|
||||
# users.users.ollama = {
|
||||
# isSystemUser = true;
|
||||
# home = "/usr/share/ollama";
|
||||
# shell = "/bin/false";
|
||||
# group = "ollama";
|
||||
# };
|
||||
# users.groups.ollama = {};
|
||||
|
||||
# systemd.services.ollama-doesnt-respect-xdg-data-home = {
|
||||
# wantedBy = ["multi-user.target"];
|
||||
# script = ''
|
||||
# mkdir -p /usr/share/ollama/.ollama
|
||||
# chown ollama:ollama -R /usr/share/ollama
|
||||
# '';
|
||||
# };
|
||||
services.ollama = {
|
||||
enable = true;
|
||||
acceleration = lib.mkIf nvidia.enable "cuda";
|
||||
listenAddress = if host == "NxACE" then "0.0.0.0:11434" else "127.0.0.1:11434";
|
||||
environmentVariables = {
|
||||
OLLAMA_ORIGINS = "*";
|
||||
};
|
||||
wantedBy = [ "default.target" ];
|
||||
};
|
||||
|
||||
users.users.ollama = {
|
||||
isSystemUser = true;
|
||||
home = "/usr/share/ollama";
|
||||
shell = "/bin/false";
|
||||
group = "ollama";
|
||||
};
|
||||
users.groups.ollama = {};
|
||||
|
||||
systemd.services.ollama-doesnt-respect-xdg-data-home = {
|
||||
wantedBy = ["multi-user.target"];
|
||||
script = ''
|
||||
mkdir -p /usr/share/ollama/.ollama
|
||||
chown ollama:ollama -R /usr/share/ollama
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user