ollama working with real /usr/share

This commit is contained in:
nx2
2024-03-07 01:16:33 +01:00
parent 7c0e37628a
commit 918b586efa

View File

@@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page, on # your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, allowed, secrets, ... }: { config, lib, pkgs, user, allowed, secrets, ... }:
{ {
imports = imports =
@@ -166,17 +166,19 @@
### OLLAMA ### OLLAMA
systemd.services.ollama = { systemd.services.ollama = {
description = "Ollama Service"; description = "Ollama Service";
after = [ "network-online.target" ]; after = [ "network-online.target" "ollama-doesnt-respect-xdg-data-home.service" ];
serviceConfig.Type = "simple"; serviceConfig = {
serviceConfig.ExecStart = "${pkgs.ollama} serve"; Type = "simple";
serviceConfig.User = "ollama"; # Environment = "\"XDG_DATA_HOME=/run/current-system/sw/share\"";
serviceConfig.Group = "ollama"; ExecStart = "${pkgs.ollama}/bin/ollama serve";
serviceConfig.Restart = "always"; User = "ollama";
serviceConfig.RestartSec = "3"; Group = "ollama";
Restart = "always";
RestartSec = "3";
};
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
}; };
users.users.ollama = { users.users.ollama = {
isSystemUser = true; isSystemUser = true;
home = "/usr/share/ollama"; home = "/usr/share/ollama";
@@ -184,6 +186,15 @@
group = "ollama"; group = "ollama";
}; };
users.groups.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
'';
};
### END OLLAMA ### END OLLAMA