fix: Trying to fix ollama service for darwin
This commit is contained in:
@@ -3,5 +3,6 @@
|
||||
./yabai.nix
|
||||
./skhd.nix
|
||||
./tailscale.nix
|
||||
./ollama.nix
|
||||
];
|
||||
}
|
||||
|
||||
17
darwin/kuro/services/ollama.nix
Normal file
17
darwin/kuro/services/ollama.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{pkgs, ...}: {
|
||||
imports = [../../../modules/ollama.nix];
|
||||
services.ollama = {
|
||||
enable = true;
|
||||
host = "127.0.0.1";
|
||||
port = 11434;
|
||||
loadModels = [
|
||||
"deepseek-r1:7b"
|
||||
# "deepseek-r1:14b"
|
||||
# "RobinBially/nomic-embed-text-8k"
|
||||
];
|
||||
environmentVariables = {
|
||||
OLLAMA_ORIGINS = "*";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
then "open"
|
||||
else "xdg-open";
|
||||
};
|
||||
sessionPath = ["${config.home.homeDirectory}/.cargo/bin"];
|
||||
sessionPath = ["${config.home.homeDirectory}/.cargo/bin" "${config.home.homeDirectory}/.local/bin"];
|
||||
|
||||
stateVersion = "23.11";
|
||||
};
|
||||
|
||||
3
justfile
3
justfile
@@ -1,13 +1,12 @@
|
||||
set dotenv-load
|
||||
|
||||
# clean := `git diff-index --quiet --cached HEAD --`
|
||||
[macos]
|
||||
install:
|
||||
nix run nix-darwin -- switch --flake .
|
||||
|
||||
[linux]
|
||||
install:
|
||||
NIX_BUILD_CORES=0 sudo nixos-rebuild switch --flake .
|
||||
sudo nixos-rebuild switch --flake .
|
||||
|
||||
[macos]
|
||||
build:
|
||||
|
||||
98
modules/ollama.nix
Normal file
98
modules/ollama.nix
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.ollama;
|
||||
in {
|
||||
options = {
|
||||
services.ollama = {
|
||||
enable = mkEnableOption "Ollama AI model runner";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.ollama;
|
||||
defaultText = literalExpression "pkgs.ollama";
|
||||
description = "The ollama package to use.";
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1";
|
||||
description = "The host address to listen on.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 11434;
|
||||
description = "The port to listen on.";
|
||||
};
|
||||
|
||||
environmentVariables = mkOption {
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
description = "Environment variables to set for the Ollama service.";
|
||||
};
|
||||
|
||||
loadModels = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "List of models to load on startup.";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/ollama";
|
||||
description = "Directory to store Ollama data.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# users.users.ollama = {
|
||||
# name = "ollama";
|
||||
# uid = 601;
|
||||
# gid = config.users.groups.ollama.gid;
|
||||
# home = cfg.dataDir;
|
||||
# createHome = true;
|
||||
# description = "Ollama service user";
|
||||
# };
|
||||
#
|
||||
# users.groups.ollama = {
|
||||
# name = "ollama";
|
||||
# gid = 602;
|
||||
# };
|
||||
|
||||
launchd.daemons.ollama = {
|
||||
path = [cfg.package];
|
||||
command = "${cfg.package}/bin/ollama serve";
|
||||
serviceConfig = {
|
||||
Label = "com.ollama.service";
|
||||
# ProgramArguments = ["serve"];
|
||||
# WorkingDirectory = cfg.dataDir;
|
||||
EnvironmentVariables =
|
||||
{
|
||||
OLLAMA_HOST = cfg.host;
|
||||
OLLAMA_PORT = toString cfg.port;
|
||||
}
|
||||
// cfg.environmentVariables;
|
||||
RunAtLoad = true;
|
||||
KeepAlive = true;
|
||||
# StandardOutPath = "/var/log/ollama.log";
|
||||
# StandardErrorPath = "/var/log/ollama.error.log";
|
||||
# UserName = "ollama";
|
||||
# GroupName = "ollama";
|
||||
};
|
||||
};
|
||||
|
||||
# system.activationScripts.preActivation.text = mkIf (cfg.loadModels != []) ''
|
||||
# # Load Ollama models
|
||||
# ${concatMapStrings (model: ''
|
||||
# ${cfg.package}/bin/ollama pull ${model}
|
||||
# '')
|
||||
# cfg.loadModels}
|
||||
# '';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user