cosmic checkpoint

This commit is contained in:
atagen 2024-08-14 01:01:53 +10:00
parent 4031a614a8
commit f623faa0ef
26 changed files with 1163 additions and 538 deletions

View file

@ -2,34 +2,30 @@
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";
};
}: {
services.podman = {
containers.ollama = {
# serviceName = "ollama";
image = "ollama/ollama:latest";
# ports = ["11434:11434"];
devices = ["nvidia.com/gpu=all"];
autostart = false;
networks = ["ollama"];
extraOptions = [
"--health-cmd"
(lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/11434'")
];
};
networks.ollama = {
Subnet = "192.168.10.0/24";
Gateway = "192.168.10.1";
};
};
# containers.ollama = {
# image = "ollama/ollama:latest";
# # TODO: volume for models!
# extraOptions = ["--network=host" "--device=nvidia.com/gpu=all"];
# };
}

View file

@ -0,0 +1,40 @@
{
lib,
pkgs,
...
}: let
port = 3021;
in {
imports = [./ollama.nix];
localWebApps = {
openwebui = {
name = "OpenWebUI";
genericName = "LLM";
icon = ../icons/openwebui.png;
inherit port;
requires.containers = ["openwebui" "ollama"];
};
};
services.podman = {
containers.openwebui = let
str = builtins.toString;
in {
# serviceName = "openwebui";
image = "ghcr.io/open-webui/open-webui:main";
ports = ["${str port}:${str port}"];
environment = {
WEBUI_AUTH = "False";
PORT = "${str port}";
};
autostart = false;
networks = ["ollama"];
unitConfig = {Requires = ["podman-ollama.service"];};
extraOptions = [
"--health-cmd"
(lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/${str port}'")
];
};
};
}

View file

@ -9,15 +9,12 @@
in {
localWebApps = {
stable-diffusion = {
name = "Stable Diffusion (ComfyUI)";
genericName = "Stable Diffusion";
name = "Stable Diffusion";
genericName = "Image Generator";
icon = ../icons/comfyui.png;
id = 5;
port = 7860;
service = {
WorkingDirectory = "${homeDirectory}/code/etc/stable-diffusion-webui-docker";
ExecStart = "${getExe pkgs.docker} compose --profile comfy up --build";
};
requires = ["stable-diffusion"];
};
};
}