-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Humaid Alqasimi <[email protected]>
- Loading branch information
1 parent
110a2ad
commit 37fbd71
Showing
8 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ config, lib, ... }: | ||
let | ||
cfg = config.ghaf.reference.services; | ||
inherit (lib) mkIf; | ||
in | ||
{ | ||
config = mkIf cfg.ollama { | ||
services.ollama = { | ||
enable = true; | ||
openFirewall = true; | ||
host = "0.0.0.0"; | ||
loadModels = [ "falcon2" ]; | ||
}; | ||
|
||
# This forces Alpaca to use the systemd ollama daemon instead of spawning | ||
# its own. | ||
system.userActivationScripts.alpaca-configure = { | ||
text = '' | ||
source ${config.system.build.setEnvironment} | ||
mkdir -p $HOME/.config/com.jeffser.Alpaca | ||
cat <<EOF > $HOME/.config/com.jeffser.Alpaca/server.json | ||
{ | ||
"remote_url": "http://localhost:11434", | ||
"remote_bearer_token": "", | ||
"run_remote": true, | ||
"local_port": 11435, | ||
"run_on_background": false, | ||
"powersaver_warning": true, | ||
"model_tweaks": { | ||
"temperature": 0.7, | ||
"seed": 0, | ||
"keep_alive": 5 | ||
}, | ||
"ollama_overrides": {}, | ||
"idle_timer": 0 | ||
} | ||
EOF | ||
''; | ||
}; | ||
|
||
# Carried over from nixpkgs | ||
# TODO remove when nixpkgs is bumped | ||
systemd.services.ollama-model-loader = { | ||
wantedBy = [ | ||
"multi-user.target" | ||
"ollama.service" | ||
]; | ||
after = [ "ollama.service" ]; | ||
bindsTo = [ "ollama.service" ]; | ||
inherit (config.systemd.services.ollama) environment; | ||
serviceConfig = { | ||
Type = "exec"; | ||
DynamicUser = true; | ||
Restart = "on-failure"; | ||
RestartSec = "1s"; | ||
RestartMaxDelaySec = "2h"; | ||
RestartSteps = "10"; | ||
}; | ||
|
||
script = '' | ||
'${lib.getExe config.services.ollama.package}' pull falcon2:latest | ||
''; | ||
}; | ||
|
||
# TODO also remove this entirely after nixpkgs bump | ||
systemd.services.ollama = { | ||
postStart = lib.mkForce ""; | ||
serviceConfig = { | ||
TimeoutStartSec = "5h"; | ||
Restart = "always"; | ||
RestartSec = "5s"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Bump to newer version of Alpaca due to a bug. | ||
# | ||
{ prev }: | ||
prev.alpaca.overrideAttrs rec { | ||
version = "2.0.6"; | ||
src = prev.fetchFromGitHub { | ||
owner = "Jeffser"; | ||
repo = "Alpaca"; | ||
rev = "refs/tags/${version}"; | ||
hash = "sha256-4c6pisd3o7mycivHd1QZ2N7s8pYzrQXiZMbVvl5ciPA="; | ||
}; | ||
|
||
patches = [ ]; | ||
postPatch = ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Use latest version of ollama. Should be removed when nixpkgs is bumped. | ||
# | ||
{ prev }: | ||
prev.ollama.overrideAttrs { | ||
src = prev.fetchFromGitHub { | ||
owner = "ollama"; | ||
repo = "ollama"; | ||
rev = "v0.3.1"; | ||
hash = "sha256-ctz9xh1wisG0YUxglygKHIvU9bMgMLkGqDoknb8qSAU="; | ||
fetchSubmodules = true; | ||
}; | ||
} |