2024-08-15 11:08:46 +00:00
|
|
|
{ config, lib, ... }:
|
2024-06-04 10:37:06 +00:00
|
|
|
let
|
|
|
|
mainPort = "8080";
|
2024-08-15 11:08:46 +00:00
|
|
|
webuiName = "NixOS Test";
|
2024-06-04 10:37:06 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "open-webui";
|
|
|
|
meta = with lib.maintainers; {
|
|
|
|
maintainers = [ shivaraj-bh ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
machine =
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
services.open-webui = {
|
|
|
|
enable = true;
|
|
|
|
environment = {
|
|
|
|
# Requires network connection
|
|
|
|
RAG_EMBEDDING_MODEL = "";
|
|
|
|
};
|
2024-08-15 11:08:46 +00:00
|
|
|
|
|
|
|
# Test that environment variables can be
|
|
|
|
# overridden through a file.
|
|
|
|
environmentFile = config.node.pkgs.writeText "test.env" ''
|
|
|
|
WEBUI_NAME="${webuiName}"
|
|
|
|
'';
|
2024-06-04 10:37:06 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2024-08-15 11:08:46 +00:00
|
|
|
import json
|
|
|
|
|
2024-06-04 10:37:06 +00:00
|
|
|
machine.start()
|
|
|
|
|
|
|
|
machine.wait_for_unit("open-webui.service")
|
|
|
|
machine.wait_for_open_port(${mainPort})
|
|
|
|
|
|
|
|
machine.succeed("curl http://127.0.0.1:${mainPort}")
|
2024-08-15 11:08:46 +00:00
|
|
|
|
|
|
|
# Load the Web UI config JSON and parse it.
|
|
|
|
webui_config_json = machine.succeed("curl http://127.0.0.1:${mainPort}/api/config")
|
|
|
|
webui_config = json.loads(webui_config_json)
|
|
|
|
|
|
|
|
# Check that the name was overridden via the environmentFile option.
|
|
|
|
assert webui_config["name"] == "${webuiName} (Open WebUI)"
|
2024-06-04 10:37:06 +00:00
|
|
|
'';
|
|
|
|
}
|