mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
ollama: add darwin support
This commit is contained in:
parent
8c0671c513
commit
daf04c5950
8 changed files with 75 additions and 3 deletions
|
|
@ -76,7 +76,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.user.services.ollama = {
|
systemd.user.services.ollama = mkIf pkgs.stdenv.isLinux {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Server for local large language models";
|
Description = "Server for local large language models";
|
||||||
After = [ "network.target" ];
|
After = [ "network.target" ];
|
||||||
|
|
@ -92,6 +92,21 @@ in {
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
Install = { WantedBy = [ "default.target" ]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
launchd.agents.ollama = mkIf pkgs.stdenv.isDarwin {
|
||||||
|
enable = true;
|
||||||
|
config = {
|
||||||
|
ProgramArguments = [ "${getExe ollamaPackage}" "serve" ];
|
||||||
|
EnvironmentVariables = cfg.environmentVariables // {
|
||||||
|
OLLAMA_HOST = "${cfg.host}:${toString cfg.port}";
|
||||||
|
};
|
||||||
|
KeepAlive = {
|
||||||
|
Crashed = true;
|
||||||
|
SuccessfulExit = false;
|
||||||
|
};
|
||||||
|
ProcessType = "Background";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
home.packages = [ ollamaPackage ];
|
home.packages = [ ollamaPackage ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,7 @@ in import nmtSrc {
|
||||||
./modules/services/git-sync-darwin
|
./modules/services/git-sync-darwin
|
||||||
./modules/services/imapnotify-darwin
|
./modules/services/imapnotify-darwin
|
||||||
./modules/services/nix-gc-darwin
|
./modules/services/nix-gc-darwin
|
||||||
|
./modules/services/ollama/darwin
|
||||||
./modules/targets-darwin
|
./modules/targets-darwin
|
||||||
] ++ lib.optionals isLinux [
|
] ++ lib.optionals isLinux [
|
||||||
./modules/config/i18n
|
./modules/config/i18n
|
||||||
|
|
@ -270,7 +271,7 @@ in import nmtSrc {
|
||||||
./modules/services/mpd-mpris
|
./modules/services/mpd-mpris
|
||||||
./modules/services/mpdris2
|
./modules/services/mpdris2
|
||||||
./modules/services/nix-gc
|
./modules/services/nix-gc
|
||||||
./modules/services/ollama
|
./modules/services/ollama/linux
|
||||||
./modules/services/osmscout-server
|
./modules/services/osmscout-server
|
||||||
./modules/services/pantalaimon
|
./modules/services/pantalaimon
|
||||||
./modules/services/parcellite
|
./modules/services/parcellite
|
||||||
|
|
|
||||||
24
tests/modules/services/ollama/darwin/basic.nix
Normal file
24
tests/modules/services/ollama/darwin/basic.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
lib.mkMerge [
|
||||||
|
{
|
||||||
|
services.ollama = {
|
||||||
|
enable = true;
|
||||||
|
host = "localhost";
|
||||||
|
port = 11111;
|
||||||
|
environmentVariables = {
|
||||||
|
OLLAMA_LLM_LIBRARY = "cpu";
|
||||||
|
HIP_VISIBLE_DEVICES = "0,1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.ollama = { };
|
||||||
|
}
|
||||||
|
(lib.mkIf pkgs.stdenv.isDarwin {
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=LaunchAgents/org.nix-community.home.ollama.plist
|
||||||
|
assertFileExists "$serviceFile"
|
||||||
|
assertFileContent "$serviceFile" ${./expected-agent.plist}
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
]
|
||||||
1
tests/modules/services/ollama/darwin/default.nix
Normal file
1
tests/modules/services/ollama/darwin/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ ollama-darwin = ./basic.nix; }
|
||||||
31
tests/modules/services/ollama/darwin/expected-agent.plist
Normal file
31
tests/modules/services/ollama/darwin/expected-agent.plist
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>EnvironmentVariables</key>
|
||||||
|
<dict>
|
||||||
|
<key>HIP_VISIBLE_DEVICES</key>
|
||||||
|
<string>0,1</string>
|
||||||
|
<key>OLLAMA_HOST</key>
|
||||||
|
<string>localhost:11111</string>
|
||||||
|
<key>OLLAMA_LLM_LIBRARY</key>
|
||||||
|
<string>cpu</string>
|
||||||
|
</dict>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<dict>
|
||||||
|
<key>Crashed</key>
|
||||||
|
<true/>
|
||||||
|
<key>SuccessfulExit</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>org.nix-community.home.ollama</string>
|
||||||
|
<key>ProcessType</key>
|
||||||
|
<string>Background</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>@ollama@/bin/ollama</string>
|
||||||
|
<string>serve</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
ollama-basic = ./basic.nix;
|
ollama-linux = ./basic.nix;
|
||||||
ollama-set-environment-variables = ./set-environment-variables.nix;
|
ollama-set-environment-variables = ./set-environment-variables.nix;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue