Files
dotfiles/system-modules/ollama.nix
2024-03-12 15:37:58 +01:00

39 lines
977 B
Nix

{ config, pkgs, lib, system, user, allowed, secrets, ... }:
{
environment.systemPackages = with pkgs; [
ollama
];
systemd.services.ollama = {
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
'';
};
}