From 918b586efa4acc90e507a85b1ba1689e8e28a193 Mon Sep 17 00:00:00 2001 From: nx2 Date: Thu, 7 Mar 2024 01:16:33 +0100 Subject: [PATCH] ollama working with real /usr/share --- configuration.nix | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/configuration.nix b/configuration.nix index 702cb71..f910cfe 100644 --- a/configuration.nix +++ b/configuration.nix @@ -2,7 +2,7 @@ # 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`). -{ config, lib, pkgs, allowed, secrets, ... }: +{ config, lib, pkgs, user, allowed, secrets, ... }: { imports = @@ -166,17 +166,19 @@ ### OLLAMA systemd.services.ollama = { description = "Ollama Service"; - after = [ "network-online.target" ]; - serviceConfig.Type = "simple"; - serviceConfig.ExecStart = "${pkgs.ollama} serve"; - serviceConfig.User = "ollama"; - serviceConfig.Group = "ollama"; - serviceConfig.Restart = "always"; - serviceConfig.RestartSec = "3"; + 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"; @@ -184,6 +186,15 @@ 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 + ''; + }; + ### END OLLAMA