mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 17:03:01 +00:00
83b1350904
When [adding Open WebUI as search engine in Firefox](https://docs.openwebui.com/tutorials/integrations/browser-search-engine/#for-firefox) it always links to `http://localhost:3000` instead of the configured port It is because [the response use `WEBUI_URL` environment variable](1d225dd804/backend/open_webui/main.py (L2370)
) which [is set by default to `1d225dd804/backend/open_webui/env.py (L106)
)
131 lines
3.8 KiB
Nix
131 lines
3.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) types;
|
|
|
|
cfg = config.services.open-webui;
|
|
in
|
|
{
|
|
options = {
|
|
services.open-webui = {
|
|
enable = lib.mkEnableOption "Open-WebUI server";
|
|
package = lib.mkPackageOption pkgs "open-webui" { };
|
|
|
|
stateDir = lib.mkOption {
|
|
type = types.path;
|
|
default = "/var/lib/open-webui";
|
|
example = "/home/foo";
|
|
description = "State directory of Open-WebUI.";
|
|
};
|
|
|
|
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 = 8080;
|
|
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.
|
|
For more details see https://docs.openwebui.com/getting-started/env-configuration/
|
|
'';
|
|
};
|
|
|
|
environmentFile = lib.mkOption {
|
|
description = ''
|
|
Environment file to be passed to the systemd service.
|
|
Useful for passing secrets to the service to prevent them from being
|
|
world-readable in the Nix store.
|
|
'';
|
|
type = lib.types.nullOr lib.types.path;
|
|
default = null;
|
|
example = "/var/lib/secrets/openWebuiSecrets";
|
|
};
|
|
|
|
openFirewall = lib.mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to open the firewall for Open-WebUI.
|
|
This adds `services.open-webui.port` to `networking.firewall.allowedTCPPorts`.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.open-webui = {
|
|
description = "User-friendly WebUI for LLMs";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
|
|
environment = {
|
|
STATIC_DIR = ".";
|
|
DATA_DIR = ".";
|
|
HF_HOME = ".";
|
|
SENTENCE_TRANSFORMERS_HOME = ".";
|
|
WEBUI_URL = "http://localhost:${toString cfg.port}";
|
|
} // cfg.environment;
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${lib.getExe cfg.package} serve --host ${cfg.host} --port ${toString cfg.port}";
|
|
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
|
|
WorkingDirectory = cfg.stateDir;
|
|
StateDirectory = "open-webui";
|
|
RuntimeDirectory = "open-webui";
|
|
RuntimeDirectoryMode = "0755";
|
|
PrivateTmp = true;
|
|
DynamicUser = true;
|
|
DevicePolicy = "closed";
|
|
LockPersonality = true;
|
|
MemoryDenyWriteExecute = false; # onnxruntime/capi/onnxruntime_pybind11_state.so: cannot enable executable stack as shared object requires: Permission Denied
|
|
PrivateUsers = true;
|
|
ProtectHome = true;
|
|
ProtectHostname = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectKernelModules = true;
|
|
ProtectKernelTunables = true;
|
|
ProtectControlGroups = true;
|
|
ProcSubset = "all"; # Error in cpuinfo: failed to parse processor information from /proc/cpuinfo
|
|
RestrictNamespaces = true;
|
|
RestrictRealtime = true;
|
|
SystemCallArchitectures = "native";
|
|
UMask = "0077";
|
|
};
|
|
};
|
|
|
|
networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };
|
|
};
|
|
|
|
meta.maintainers = with lib.maintainers; [ shivaraj-bh ];
|
|
}
|