more webapp stuff
This commit is contained in:
parent
9bc61077d5
commit
533f88f4cd
4 changed files with 34 additions and 15 deletions
|
@ -21,7 +21,8 @@
|
|||
|
||||
localWebApps = {
|
||||
stable-diffusion = {
|
||||
name = "ComfyUI (Stable Diffusion)";
|
||||
name = "Stable Diffusion (ComfyUI)";
|
||||
genericName = "Stable Diffusion";
|
||||
icon = ./icons/comfyui.png;
|
||||
id = 5;
|
||||
port = 7860;
|
||||
|
@ -32,7 +33,8 @@
|
|||
};
|
||||
|
||||
openwebui = rec {
|
||||
name = "OpenWebUI (Ollama)";
|
||||
name = "Ollama (OpenWebUI)";
|
||||
genericName = "Ollama";
|
||||
icon = ./icons/openwebui.png;
|
||||
id = 6;
|
||||
port = 3021;
|
||||
|
@ -40,9 +42,17 @@
|
|||
docker = lib.getExe pkgs.docker;
|
||||
in {
|
||||
Type = "exec";
|
||||
ExecStartPre = "-${docker} create -e PORT=${builtins.toString port} --network host --gpus all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama";
|
||||
ExecStart = "${docker} start open-webui";
|
||||
ExecStop = "${docker} stop open-webui";
|
||||
ExecStartPre = "${pkgs.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=${builtins.toString port} --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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -128,12 +128,12 @@ in {
|
|||
name = "Facebook Messenger";
|
||||
icon = ./icons/fb_msg.png;
|
||||
};
|
||||
"ChatGPT" = {
|
||||
url = "https://chat.openai.com";
|
||||
"Syncthing" = {
|
||||
url = "http://127.0.0.1:8384";
|
||||
id = 3;
|
||||
extraSettings = config.programs.firefox.profiles.default.settings;
|
||||
name = "ChatGPT";
|
||||
icon = ./icons/ChatGPT.png;
|
||||
name = "Syncthing";
|
||||
icon = ./icons/syncthing.png;
|
||||
};
|
||||
"StudyTAFE" = {
|
||||
url = "https://www.studytafensw.edu.au";
|
||||
|
|
BIN
home/icons/syncthing.png
Normal file
BIN
home/icons/syncthing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 86 KiB |
|
@ -6,6 +6,7 @@
|
|||
}: let
|
||||
inherit (lib) mkOption;
|
||||
inherit (lib.attrsets) mapAttrs mapAttrs' nameValuePair;
|
||||
# make a firefox webapp entry for the client app
|
||||
make-firefox = cfg:
|
||||
mapAttrs' (
|
||||
name: cfg:
|
||||
|
@ -18,6 +19,7 @@
|
|||
}
|
||||
)
|
||||
cfg;
|
||||
# make a systemd service for running the backend
|
||||
make-systemd = cfg:
|
||||
mapAttrs (
|
||||
name: cfg: {
|
||||
|
@ -26,12 +28,12 @@
|
|||
}
|
||||
)
|
||||
cfg;
|
||||
# make desktop shortcuts and a script which will handle starting both the above
|
||||
make-xdg = cfg:
|
||||
mapAttrs (
|
||||
name: cfg: {
|
||||
name = cfg.name;
|
||||
inherit (cfg) name icon genericName;
|
||||
type = "Application";
|
||||
icon = cfg.icon;
|
||||
exec = "${let
|
||||
notify-send = "${lib.getExe' pkgs.libnotify "notify-send"} -a \"${cfg.name}\"";
|
||||
systemctl = "${lib.getExe' pkgs.systemd "systemctl"}";
|
||||
|
@ -40,13 +42,14 @@
|
|||
in
|
||||
pkgs.writeShellScript "${name}"
|
||||
''
|
||||
set -euo pipefail
|
||||
${notify-send} "Launching backend.." "Please be patient."
|
||||
${systemctl} --user start ${name}
|
||||
attempts=0
|
||||
success=false
|
||||
|
||||
while [[ $attempts -lt $((20*9)) ]]; do
|
||||
if [[ $(${curl} http://127.0.0.1:${builtins.toString cfg.port}) ]]; then
|
||||
if [[ $(${curl} -sf http://127.0.0.1:${builtins.toString cfg.port} --output /dev/null; printf $?) -eq 0 ]]; then
|
||||
${notify-send} "Backend up." "Launching client.."
|
||||
success=true
|
||||
break
|
||||
|
@ -85,10 +88,16 @@ in {
|
|||
description = "Display name of the webapp.";
|
||||
};
|
||||
|
||||
genericName = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Generic name of the webapp.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
icon = mkOption {
|
||||
type = either str path;
|
||||
type = nullOr (either str path);
|
||||
description = "Path to a file to use for application icon.";
|
||||
default = "";
|
||||
default = null;
|
||||
};
|
||||
|
||||
id = mkOption {
|
||||
|
@ -102,7 +111,7 @@ in {
|
|||
};
|
||||
|
||||
service = mkOption {
|
||||
type = attrsOf string;
|
||||
type = attrsOf str;
|
||||
description = "The service settings for systemd user service. Requires at least ExecStart.";
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue