35 lines
1.1 KiB
Nix
35 lines
1.1 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
inherit (lib) getExe;
|
|
inherit (builtins) toString;
|
|
inherit (pkgs) writeShellScript;
|
|
in {
|
|
localWebApps = {
|
|
openwebui = rec {
|
|
name = "Ollama (OpenWebUI)";
|
|
genericName = "Ollama";
|
|
icon = ../icons/openwebui.png;
|
|
id = 6;
|
|
port = 3021;
|
|
service = let
|
|
docker = getExe pkgs.docker;
|
|
in {
|
|
Type = "exec";
|
|
ExecStartPre = "${writeShellScript "openwebui-check" ''
|
|
set -euo pipefail
|
|
echo Checking for container existence..
|
|
if [[ $(${docker} inspect openwebui &> /dev/null; printf $?) -ne 0 ]]; then
|
|
echo Not found. Creating OpenWebUI/Ollama container..
|
|
${docker} create -e PORT=${toString port} --restart no --network host --gpus all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name openwebui --restart always ghcr.io/open-webui/open-webui:ollama
|
|
fi
|
|
echo Check complete.
|
|
''}";
|
|
ExecStart = "${docker} start -a openwebui";
|
|
ExecStop = "${docker} stop openwebui";
|
|
};
|
|
};
|
|
};
|
|
}
|