Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildNpmPackage, 4 fetchFromGitHub, 5 python3Packages, 6 nixosTests, 7 fetchurl, 8 ffmpeg-headless, 9}: 10let 11 pname = "open-webui"; 12 version = "0.6.18"; 13 14 src = fetchFromGitHub { 15 owner = "open-webui"; 16 repo = "open-webui"; 17 tag = "v${version}"; 18 hash = "sha256-1V9mOhO8jpr0HU0djLjKw6xDQMBmqie6Gte4xfg9PfQ="; 19 }; 20 21 frontend = buildNpmPackage rec { 22 pname = "open-webui-frontend"; 23 inherit version src; 24 25 # the backend for run-on-client-browser python execution 26 # must match lock file in open-webui 27 # TODO: should we automate this? 28 # TODO: with JQ? "jq -r '.packages["node_modules/pyodide"].version' package-lock.json" 29 pyodideVersion = "0.28.0"; 30 pyodide = fetchurl { 31 hash = "sha256-4YwDuhcWPYm40VKfOEqPeUSIRQl1DDAdXEUcMuzzU7o="; 32 url = "https://github.com/pyodide/pyodide/releases/download/${pyodideVersion}/pyodide-${pyodideVersion}.tar.bz2"; 33 }; 34 35 npmDepsHash = "sha256-bMqK9NvuTwqnhflGDfZTEkaFG8y34Qf94SgR0HMClrQ="; 36 37 # See https://github.com/open-webui/open-webui/issues/15880 38 npmFlags = [ 39 "--force" 40 "--legacy-peer-deps" 41 ]; 42 43 # Disabling `pyodide:fetch` as it downloads packages during `buildPhase` 44 # Until this is solved, running python packages from the browser will not work. 45 postPatch = '' 46 substituteInPlace package.json \ 47 --replace-fail "npm run pyodide:fetch && vite build" "vite build" 48 ''; 49 50 propagatedBuildInputs = [ 51 ffmpeg-headless 52 ]; 53 54 env.CYPRESS_INSTALL_BINARY = "0"; # disallow cypress from downloading binaries in sandbox 55 env.ONNXRUNTIME_NODE_INSTALL_CUDA = "skip"; 56 env.NODE_OPTIONS = "--max-old-space-size=8192"; 57 58 preBuild = '' 59 tar xf ${pyodide} -C static/ 60 ''; 61 62 installPhase = '' 63 runHook preInstall 64 65 mkdir -p $out/share 66 cp -a build $out/share/open-webui 67 68 runHook postInstall 69 ''; 70 }; 71in 72python3Packages.buildPythonApplication rec { 73 inherit pname version src; 74 pyproject = true; 75 76 build-system = with python3Packages; [ hatchling ]; 77 78 # Not force-including the frontend build directory as frontend is managed by the `frontend` derivation above. 79 postPatch = '' 80 substituteInPlace pyproject.toml \ 81 --replace-fail ', build = "open_webui/frontend"' "" 82 ''; 83 84 env.HATCH_BUILD_NO_HOOKS = true; 85 86 pythonRelaxDeps = true; 87 88 pythonRemoveDeps = [ 89 "docker" 90 "pytest" 91 "pytest-docker" 92 ]; 93 94 dependencies = 95 with python3Packages; 96 [ 97 accelerate 98 aiocache 99 aiofiles 100 aiohttp 101 alembic 102 anthropic 103 apscheduler 104 argon2-cffi 105 asgiref 106 async-timeout 107 authlib 108 azure-ai-documentintelligence 109 azure-identity 110 azure-storage-blob 111 bcrypt 112 beautifulsoup4 113 black 114 boto3 115 chromadb 116 colbert-ai 117 cryptography 118 ddgs 119 docx2txt 120 einops 121 elasticsearch 122 extract-msg 123 fake-useragent 124 fastapi 125 faster-whisper 126 firecrawl-py 127 fpdf2 128 ftfy 129 gcp-storage-emulator 130 google-api-python-client 131 google-auth-httplib2 132 google-auth-oauthlib 133 google-cloud-storage 134 google-genai 135 google-generativeai 136 googleapis-common-protos 137 httpx 138 iso-639 139 langchain 140 langchain-community 141 langdetect 142 langfuse 143 ldap3 144 loguru 145 markdown 146 moto 147 nltk 148 onnxruntime 149 openai 150 opencv-python-headless 151 openpyxl 152 opensearch-py 153 opentelemetry-api 154 opentelemetry-sdk 155 opentelemetry-exporter-otlp 156 opentelemetry-instrumentation 157 opentelemetry-instrumentation-fastapi 158 opentelemetry-instrumentation-sqlalchemy 159 opentelemetry-instrumentation-redis 160 opentelemetry-instrumentation-requests 161 opentelemetry-instrumentation-logging 162 opentelemetry-instrumentation-httpx 163 opentelemetry-instrumentation-aiohttp-client 164 pandas 165 passlib 166 peewee 167 peewee-migrate 168 pgvector 169 pillow 170 pinecone-client 171 playwright 172 posthog 173 psutil 174 psycopg2-binary 175 pycrdt 176 pydub 177 pyjwt 178 pymdown-extensions 179 pymilvus 180 pymongo 181 pymysql 182 pypandoc 183 pypdf 184 python-dotenv 185 python-jose 186 python-multipart 187 python-pptx 188 python-socketio 189 pytube 190 pyxlsb 191 qdrant-client 192 rank-bm25 193 rapidocr-onnxruntime 194 redis 195 requests 196 restrictedpython 197 sentence-transformers 198 sentencepiece 199 soundfile 200 starlette-compress 201 tencentcloud-sdk-python 202 tiktoken 203 transformers 204 unstructured 205 uvicorn 206 validators 207 xlrd 208 youtube-transcript-api 209 ] 210 ++ moto.optional-dependencies.s3; 211 212 pythonImportsCheck = [ "open_webui" ]; 213 214 makeWrapperArgs = [ "--set FRONTEND_BUILD_DIR ${frontend}/share/open-webui" ]; 215 216 passthru = { 217 tests = { 218 inherit (nixosTests) open-webui; 219 }; 220 updateScript = ./update.sh; 221 inherit frontend; 222 }; 223 224 meta = { 225 changelog = "https://github.com/open-webui/open-webui/blob/${src.tag}/CHANGELOG.md"; 226 description = "Comprehensive suite for LLMs with a user-friendly WebUI"; 227 homepage = "https://github.com/open-webui/open-webui"; 228 # License history is complex: originally MIT, then a potentially problematic 229 # relicensing to a modified BSD-3 clause occurred around v0.5.5/v0.6.6. 230 # Due to these concerns and non-standard terms, it's treated as custom non-free. 231 license = { 232 fullName = "Open WebUI License"; 233 url = "https://github.com/open-webui/open-webui/blob/0cef844168e97b70de2abee4c076cc30ffec6193/LICENSE"; 234 # Marked non-free due to concerns over the MIT -> modified BSD-3 relicensing process, 235 # potentially unclear/contradictory statements, and non-standard branding requirements. 236 free = false; 237 }; 238 longDescription = '' 239 User-friendly WebUI for LLMs. Note on licensing: Code in Open WebUI prior 240 to version 0.5.5 was MIT licensed. Since version 0.6.6, the project has 241 adopted a modified BSD-3-Clause license that includes branding requirements 242 and whose relicensing process from MIT has raised concerns within the community. 243 Nixpkgs treats this custom license as non-free due to these factors. 244 ''; 245 mainProgram = "open-webui"; 246 maintainers = with lib.maintainers; [ 247 drupol 248 shivaraj-bh 249 ]; 250 }; 251}