10 cfg = config.services.open-webui;
14 services.open-webui = {
15 enable = lib.mkEnableOption "Open-WebUI server";
16 package = lib.mkPackageOption pkgs "open-webui" { };
18 stateDir = lib.mkOption {
20 default = "/var/lib/open-webui";
21 example = "/home/foo";
22 description = "State directory of Open-WebUI.";
27 default = "127.0.0.1";
30 The host address which the Open-WebUI server HTTP interface listens to.
39 Which port the Open-WebUI server listens to.
43 environment = lib.mkOption {
44 type = types.attrsOf types.str;
46 SCARF_NO_ANALYTICS = "True";
47 DO_NOT_TRACK = "True";
48 ANONYMIZED_TELEMETRY = "False";
52 OLLAMA_API_BASE_URL = "http://127.0.0.1:11434";
53 # Disable authentication
58 Extra environment variables for Open-WebUI.
59 For more details see https://docs.openwebui.com/getting-started/advanced-topics/env-configuration/
63 environmentFile = lib.mkOption {
65 Environment file to be passed to the systemd service.
66 Useful for passing secrets to the service to prevent them from being
67 world-readable in the Nix store.
69 type = lib.types.nullOr lib.types.path;
71 example = "/var/lib/secrets/openWebuiSecrets";
74 openFirewall = lib.mkOption {
78 Whether to open the firewall for Open-WebUI.
79 This adds `services.open-webui.port` to `networking.firewall.allowedTCPPorts`.
85 config = lib.mkIf cfg.enable {
86 systemd.services.open-webui = {
87 description = "User-friendly WebUI for LLMs";
88 wantedBy = [ "multi-user.target" ];
89 after = [ "network.target" ];
95 SENTENCE_TRANSFORMERS_HOME = ".";
96 WEBUI_URL = "http://localhost:${toString cfg.port}";
100 ExecStart = "${lib.getExe cfg.package} serve --host ${cfg.host} --port ${toString cfg.port}";
101 EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
102 WorkingDirectory = cfg.stateDir;
103 StateDirectory = "open-webui";
104 RuntimeDirectory = "open-webui";
105 RuntimeDirectoryMode = "0755";
108 DevicePolicy = "closed";
109 LockPersonality = true;
110 MemoryDenyWriteExecute = false; # onnxruntime/capi/onnxruntime_pybind11_state.so: cannot enable executable stack as shared object requires: Permission Denied
113 ProtectHostname = true;
114 ProtectKernelLogs = true;
115 ProtectKernelModules = true;
116 ProtectKernelTunables = true;
117 ProtectControlGroups = true;
118 ProcSubset = "all"; # Error in cpuinfo: failed to parse processor information from /proc/cpuinfo
119 RestrictNamespaces = true;
120 RestrictRealtime = true;
121 SystemCallArchitectures = "native";
126 networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };
129 meta.maintainers = with lib.maintainers; [ shivaraj-bh ];