2022-03-30 09:31:56 +00:00
|
|
|
{ lib
|
|
|
|
, fetchurl
|
|
|
|
, nixosTests
|
|
|
|
, python3
|
|
|
|
, ghostscript
|
2022-09-14 18:05:37 +00:00
|
|
|
, imagemagickBig
|
2022-03-30 09:31:56 +00:00
|
|
|
, jbig2enc
|
|
|
|
, optipng
|
|
|
|
, pngquant
|
|
|
|
, qpdf
|
2022-09-30 11:47:45 +00:00
|
|
|
, tesseract5
|
2022-03-30 09:31:56 +00:00
|
|
|
, unpaper
|
2023-01-11 07:51:40 +00:00
|
|
|
, poppler_utils
|
2022-03-30 09:31:56 +00:00
|
|
|
, liberation_ttf
|
2022-08-12 12:06:08 +00:00
|
|
|
, fetchFromGitHub
|
2022-03-30 09:31:56 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-06-16 17:23:12 +00:00
|
|
|
# Use specific package versions required by paperless-ngx
|
2022-09-09 14:08:57 +00:00
|
|
|
python = python3.override {
|
2022-03-30 09:31:56 +00:00
|
|
|
packageOverrides = self: super: {
|
2022-06-16 17:23:12 +00:00
|
|
|
django = super.django_4;
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
aioredis = super.aioredis.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "1.3.1";
|
|
|
|
src = oldAttrs.src.override {
|
|
|
|
inherit version;
|
|
|
|
sha256 = "0fi7jd5hlx8cnv1m97kv9hc4ih4l8v15wzkqwsp73is4n0qazy0m";
|
|
|
|
};
|
|
|
|
});
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
# downgrade redis due to https://github.com/paperless-ngx/paperless-ngx/pull/1802
|
|
|
|
# and https://github.com/django/channels_redis/issues/332
|
|
|
|
channels-redis = super.channels-redis.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "3.4.1";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "django";
|
|
|
|
repo = "channels_redis";
|
|
|
|
rev = version;
|
|
|
|
hash = "sha256-ZQSsE3pkM+nfDhWutNuupcyC5MDikUu6zU4u7Im6bRQ=";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
channels = super.channels.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "3.0.5";
|
|
|
|
pname = "channels";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "django";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
|
|
|
sha256 = "sha256-bKrPLbD9zG7DwIYBst1cb+zkDsM8B02wh3D80iortpw=";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ self.daphne ];
|
2022-11-21 17:40:18 +00:00
|
|
|
pytestFlagsArray = [ "--asyncio-mode=auto" ];
|
2022-10-30 15:09:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
daphne = super.daphne.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "3.0.2";
|
|
|
|
pname = "daphne";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "django";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
|
|
|
hash = "sha256-KWkMV4L7bA2Eo/u4GGif6lmDNrZAzvYyDiyzyWt9LeI=";
|
|
|
|
};
|
2022-09-30 11:47:45 +00:00
|
|
|
});
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
path = lib.makeBinPath [
|
|
|
|
ghostscript
|
|
|
|
imagemagickBig
|
|
|
|
jbig2enc
|
|
|
|
optipng
|
|
|
|
pngquant
|
|
|
|
qpdf
|
2022-09-30 11:47:45 +00:00
|
|
|
tesseract5
|
2022-09-14 18:05:37 +00:00
|
|
|
unpaper
|
2023-01-11 07:51:40 +00:00
|
|
|
poppler_utils
|
2022-09-14 18:05:37 +00:00
|
|
|
];
|
2022-03-30 09:31:56 +00:00
|
|
|
in
|
2022-09-09 14:08:57 +00:00
|
|
|
python.pkgs.pythonPackages.buildPythonApplication rec {
|
2022-03-30 09:31:56 +00:00
|
|
|
pname = "paperless-ngx";
|
2022-12-28 21:21:41 +00:00
|
|
|
version = "1.10.2";
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
# Fetch the release tarball instead of a git ref because it contains the prebuilt frontend
|
2022-03-30 09:31:56 +00:00
|
|
|
src = fetchurl {
|
2022-06-16 17:23:12 +00:00
|
|
|
url = "https://github.com/paperless-ngx/paperless-ngx/releases/download/v${version}/${pname}-v${version}.tar.xz";
|
2022-12-28 21:21:41 +00:00
|
|
|
hash = "sha256-uOrRHHNqIYsDbzKcA7EsYZjadpLyAB4Ks+PU+BNsTWE=";
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
format = "other";
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
propagatedBuildInputs = with python.pkgs.pythonPackages; [
|
2022-03-30 09:31:56 +00:00
|
|
|
aioredis
|
|
|
|
arrow
|
|
|
|
asgiref
|
|
|
|
async-timeout
|
|
|
|
attrs
|
|
|
|
autobahn
|
|
|
|
automat
|
|
|
|
blessed
|
2022-12-28 21:21:41 +00:00
|
|
|
celery
|
2022-03-30 09:31:56 +00:00
|
|
|
certifi
|
|
|
|
cffi
|
|
|
|
channels-redis
|
|
|
|
channels
|
|
|
|
chardet
|
|
|
|
click
|
|
|
|
coloredlogs
|
|
|
|
concurrent-log-handler
|
|
|
|
constantly
|
|
|
|
cryptography
|
|
|
|
daphne
|
|
|
|
dateparser
|
2022-12-28 21:21:41 +00:00
|
|
|
django-celery-results
|
2022-03-30 09:31:56 +00:00
|
|
|
django-cors-headers
|
|
|
|
django-extensions
|
|
|
|
django-filter
|
|
|
|
django-picklefield
|
|
|
|
django
|
|
|
|
djangorestframework
|
|
|
|
filelock
|
|
|
|
fuzzywuzzy
|
|
|
|
gunicorn
|
|
|
|
h11
|
|
|
|
hiredis
|
|
|
|
httptools
|
|
|
|
humanfriendly
|
|
|
|
hyperlink
|
|
|
|
idna
|
|
|
|
imap-tools
|
|
|
|
img2pdf
|
|
|
|
incremental
|
|
|
|
inotify-simple
|
|
|
|
inotifyrecursive
|
|
|
|
joblib
|
|
|
|
langdetect
|
|
|
|
lxml
|
|
|
|
msgpack
|
|
|
|
numpy
|
|
|
|
ocrmypdf
|
|
|
|
pathvalidate
|
2022-06-16 17:23:12 +00:00
|
|
|
pdf2image
|
|
|
|
pdfminer-six
|
2022-03-30 09:31:56 +00:00
|
|
|
pikepdf
|
|
|
|
pillow
|
|
|
|
pluggy
|
|
|
|
portalocker
|
|
|
|
psycopg2
|
|
|
|
pyasn1-modules
|
|
|
|
pyasn1
|
|
|
|
pycparser
|
|
|
|
pyopenssl
|
|
|
|
python-dateutil
|
|
|
|
python-dotenv
|
|
|
|
python-gnupg
|
|
|
|
python-Levenshtein
|
2022-05-18 14:49:53 +00:00
|
|
|
python-magic
|
2022-03-30 09:31:56 +00:00
|
|
|
pytz
|
|
|
|
pyyaml
|
2022-06-16 17:23:12 +00:00
|
|
|
pyzbar
|
2022-12-28 21:21:41 +00:00
|
|
|
rapidfuzz
|
2022-03-30 09:31:56 +00:00
|
|
|
redis
|
|
|
|
regex
|
|
|
|
reportlab
|
|
|
|
requests
|
|
|
|
scikit-learn
|
|
|
|
scipy
|
|
|
|
service-identity
|
|
|
|
six
|
|
|
|
sortedcontainers
|
|
|
|
sqlparse
|
|
|
|
threadpoolctl
|
|
|
|
tika
|
|
|
|
tqdm
|
2022-06-16 17:23:12 +00:00
|
|
|
twisted.optional-dependencies.tls
|
2022-03-30 09:31:56 +00:00
|
|
|
txaio
|
|
|
|
tzlocal
|
|
|
|
urllib3
|
|
|
|
uvicorn
|
|
|
|
uvloop
|
|
|
|
watchdog
|
|
|
|
watchgod
|
|
|
|
wcwidth
|
|
|
|
websockets
|
|
|
|
whitenoise
|
|
|
|
whoosh
|
|
|
|
zope_interface
|
|
|
|
];
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Compile manually because `pythonRecompileBytecodeHook` only works for
|
|
|
|
# files in `python.sitePackages`
|
|
|
|
postBuild = ''
|
2022-09-09 14:08:57 +00:00
|
|
|
${python.interpreter} -OO -m compileall src
|
2022-04-15 01:41:22 +00:00
|
|
|
'';
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
cp -r . $out/lib/paperless-ngx
|
|
|
|
chmod +x $out/lib/paperless-ngx/src/manage.py
|
|
|
|
makeWrapper $out/lib/paperless-ngx/src/manage.py $out/bin/paperless-ngx \
|
|
|
|
--prefix PYTHONPATH : "$PYTHONPATH" \
|
|
|
|
--prefix PATH : "${path}"
|
2022-12-28 21:21:41 +00:00
|
|
|
makeWrapper ${python.pkgs.celery}/bin/celery $out/bin/celery \
|
|
|
|
--prefix PYTHONPATH : "$PYTHONPATH:$out/lib/paperless-ngx/src" \
|
|
|
|
--prefix PATH : "${path}"
|
2022-03-30 09:31:56 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
checkInputs = with python.pkgs.pythonPackages; [
|
2022-03-30 09:31:56 +00:00
|
|
|
pytest-django
|
|
|
|
pytest-env
|
|
|
|
pytest-sugar
|
|
|
|
pytest-xdist
|
|
|
|
factory_boy
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"src"
|
|
|
|
];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
|
|
|
# The tests require:
|
|
|
|
# - PATH with runtime binaries
|
|
|
|
# - A temporary HOME directory for gnupg
|
|
|
|
# - XDG_DATA_DIRS with test-specific fonts
|
|
|
|
preCheck = ''
|
|
|
|
export PATH="${path}:$PATH"
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
export XDG_DATA_DIRS="${liberation_ttf}/share:$XDG_DATA_DIRS"
|
|
|
|
|
|
|
|
# Disable unneeded code coverage test
|
|
|
|
substituteInPlace src/setup.cfg \
|
|
|
|
--replace "--cov --cov-report=html" ""
|
2022-12-28 21:21:41 +00:00
|
|
|
# OCR on NixOS recognizes the space in the picture, upstream CI doesn't.
|
|
|
|
# See https://github.com/paperless-ngx/paperless-ngx/pull/2216
|
|
|
|
substituteInPlace src/paperless_tesseract/tests/test_parser.py \
|
|
|
|
--replace "this is awebp document" "this is a webp document"
|
2022-03-30 09:31:56 +00:00
|
|
|
'';
|
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
disabledTests = [
|
|
|
|
# FileNotFoundError(2, 'No such file or directory'): /build/tmp...
|
|
|
|
"test_script_with_output"
|
|
|
|
# AssertionError: 10 != 4 (timezone/time issue)
|
|
|
|
# Due to getting local time from modification date in test_consumer.py
|
|
|
|
"testNormalOperation"
|
|
|
|
];
|
2022-10-30 15:09:59 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
passthru = {
|
2022-09-09 14:08:57 +00:00
|
|
|
inherit python path;
|
2022-04-15 01:41:22 +00:00
|
|
|
tests = { inherit (nixosTests) paperless; };
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
2022-10-30 15:09:59 +00:00
|
|
|
description = "Tool to scan, index, and archive all of your physical documents";
|
|
|
|
homepage = "https://paperless-ngx.readthedocs.io/";
|
2022-03-30 09:31:56 +00:00
|
|
|
license = licenses.gpl3Only;
|
2022-07-14 12:49:19 +00:00
|
|
|
maintainers = with maintainers; [ lukegb gador erikarvstedt ];
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
|
|
|
}
|