-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ported from: https://github.com/shivaraj-bh/ollama-flake/blob/main/services/open-webui.nix This was also recently upstreamed to nixpkgs: NixOS/nixpkgs#316248
- Loading branch information
1 parent
3e68d66
commit 399b858
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ in | |
./mysql | ||
./nginx | ||
./postgres | ||
./open-webui.nix | ||
./redis-cluster.nix | ||
./redis.nix | ||
./zookeeper.nix | ||
|
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,95 @@ | ||
# Based on: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/open-webui.nix | ||
{ pkgs, lib, name, config, ... }: | ||
let | ||
inherit (lib) types; | ||
in | ||
{ | ||
options = { | ||
enable = lib.mkEnableOption "Open-WebUI server"; | ||
package = lib.mkPackageOption pkgs "open-webui" { }; | ||
|
||
dataDir = lib.mkOption { | ||
type = types.str; | ||
default = "./data/${name}"; | ||
description = "The Open-WebUI data directory"; | ||
}; | ||
|
||
host = lib.mkOption { | ||
type = types.str; | ||
default = "127.0.0.1"; | ||
example = "0.0.0.0"; | ||
description = '' | ||
The host address which the Open-WebUI server HTTP interface listens to. | ||
''; | ||
}; | ||
|
||
port = lib.mkOption { | ||
type = types.port; | ||
default = 1111; | ||
example = 11111; | ||
description = '' | ||
Which port the Open-WebUI server listens to. | ||
''; | ||
}; | ||
|
||
environment = lib.mkOption { | ||
type = types.attrsOf types.str; | ||
default = { | ||
SCARF_NO_ANALYTICS = "True"; | ||
DO_NOT_TRACK = "True"; | ||
ANONYMIZED_TELEMETRY = "False"; | ||
}; | ||
example = '' | ||
{ | ||
OLLAMA_API_BASE_URL = "http://127.0.0.1:11434"; | ||
# Disable authentication | ||
WEBUI_AUTH = "False"; | ||
} | ||
''; | ||
description = "Extra environment variables for Open-WebUI"; | ||
}; | ||
|
||
outputs.settings = lib.mkOption { | ||
type = types.deferredModule; | ||
internal = true; | ||
readOnly = true; | ||
default = { | ||
processes = { | ||
"${name}" = { | ||
inherit (config) environment; | ||
command = pkgs.writeShellApplication { | ||
name = "open-webui-wrapper"; | ||
runtimeInputs = [ pkgs.open-webui ]; | ||
text = '' | ||
set -x | ||
if [ ! -d ${config.dataDir} ]; then | ||
mkdir -p ${config.dataDir} | ||
fi | ||
DATA_DIR=$(readlink -f ${config.dataDir}) | ||
STATIC_DIR=$DATA_DIR | ||
HF_HOME=$DATA_DIR | ||
SENTENCE_TRANSFORMERS_HOME=$DATA_DIR | ||
export DATA_DIR STATIC_DIR HF_HOME SENTENCE_TRANSFORMERS_HOME | ||
open-webui serve --host ${config.host} --port ${builtins.toString config.port} | ||
''; | ||
}; | ||
readiness_probe = { | ||
http_get = { | ||
host = config.host; | ||
port = config.port; | ||
}; | ||
initial_delay_seconds = 2; | ||
period_seconds = 10; | ||
timeout_seconds = 4; | ||
success_threshold = 1; | ||
failure_threshold = 5; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
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,21 @@ | ||
{ pkgs, ... }: { | ||
services.open-webui."open-webui1" = { | ||
enable = true; | ||
environment = { | ||
# Requires network connection | ||
RAG_EMBEDDING_MODEL = ""; | ||
}; | ||
}; | ||
|
||
settings.processes.test = { | ||
command = pkgs.writeShellApplication { | ||
runtimeInputs = [ pkgs.curl ]; | ||
text = '' | ||
# Avoid printing the entire HTML page on the stdout, we just want to know if the page is active. | ||
curl http://127.0.0.1:1111 > /dev/null | ||
''; | ||
name = "open-webui-test"; | ||
}; | ||
depends_on."open-webui1".condition = "process_healthy"; | ||
}; | ||
} |
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