1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pytestCheckHook, 6 hatchling, 7 argostranslate, 8 flask, 9 flask-swagger, 10 flask-swagger-ui, 11 flask-limiter, 12 flask-babel, 13 flask-session, 14 waitress, 15 expiringdict, 16 langdetect, 17 lexilang, 18 ltpycld2, 19 morfessor, 20 appdirs, 21 apscheduler, 22 translatehtml, 23 argos-translate-files, 24 requests, 25 redis, 26 prometheus-client, 27 polib, 28 python, 29}: 30 31buildPythonPackage rec { 32 pname = "libretranslate"; 33 version = "1.6.5"; 34 pyproject = true; 35 36 src = fetchFromGitHub { 37 owner = "LibreTranslate"; 38 repo = "LibreTranslate"; 39 tag = "v${version}"; 40 hash = "sha256-fzBVEJnj7sCkfNIIFZXHB0VQt94z0U9lbtW6+abAMpA="; 41 }; 42 43 build-system = [ 44 hatchling 45 ]; 46 47 pythonRelaxDeps = true; 48 49 dependencies = [ 50 argostranslate 51 flask 52 flask-swagger 53 flask-swagger-ui 54 flask-limiter 55 flask-babel 56 flask-session 57 waitress 58 expiringdict 59 langdetect 60 lexilang 61 ltpycld2 62 morfessor 63 appdirs 64 apscheduler 65 translatehtml 66 argos-translate-files 67 requests 68 redis 69 prometheus-client 70 polib 71 ]; 72 73 postInstall = '' 74 # expose static files to be able to serve them via web-server 75 mkdir -p $out/share/libretranslate 76 ln -s $out/${python.sitePackages}/libretranslate/static $out/share/libretranslate/static 77 ''; 78 79 doCheck = false; # needs network access 80 81 nativeCheckInputs = [ pytestCheckHook ]; 82 83 # required for import check to work (argostranslate) 84 env.HOME = "/tmp"; 85 86 pythonImportsCheck = [ "libretranslate" ]; 87 88 meta = with lib; { 89 description = "Free and Open Source Machine Translation API. Self-hosted, no limits, no ties to proprietary services"; 90 homepage = "https://libretranslate.com"; 91 changelog = "https://github.com/LibreTranslate/LibreTranslate/releases/tag/${src.tag}"; 92 license = licenses.agpl3Only; 93 maintainers = with maintainers; [ misuzu ]; 94 }; 95}