2022-04-04 18:30:41 +00:00
|
|
|
{ lib
|
2023-02-08 20:45:25 +00:00
|
|
|
, stdenv
|
2023-01-29 22:59:57 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, buildNpmPackage
|
2022-04-04 18:30:41 +00:00
|
|
|
, nixosTests
|
2023-01-29 22:59:57 +00:00
|
|
|
, gettext
|
2022-04-04 18:30:41 +00:00
|
|
|
, python3
|
|
|
|
, ghostscript
|
2022-09-11 19:55:13 +00:00
|
|
|
, imagemagickBig
|
2022-04-04 18:30:41 +00:00
|
|
|
, jbig2enc
|
|
|
|
, optipng
|
|
|
|
, pngquant
|
|
|
|
, qpdf
|
2022-09-21 13:34:42 +00:00
|
|
|
, tesseract5
|
2022-04-04 18:30:41 +00:00
|
|
|
, unpaper
|
2023-01-02 08:59:58 +00:00
|
|
|
, poppler_utils
|
2022-04-04 18:30:41 +00:00
|
|
|
, liberation_ttf
|
2023-02-08 20:45:25 +00:00
|
|
|
, xcbuild
|
2023-12-06 22:35:40 +00:00
|
|
|
, pango
|
|
|
|
, pkg-config
|
2022-04-04 18:30:41 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-12-28 12:20:08 +00:00
|
|
|
version = "2.2.1";
|
2023-01-29 22:59:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "paperless-ngx";
|
|
|
|
repo = "paperless-ngx";
|
|
|
|
rev = "refs/tags/v${version}";
|
2023-12-28 12:20:08 +00:00
|
|
|
hash = "sha256-ds/hQ0+poUTO2bnXiHvNUanVFJcxxyuW3a9Yxcq5cAg=";
|
2023-01-29 22:59:57 +00:00
|
|
|
};
|
|
|
|
|
2023-11-29 20:08:10 +00:00
|
|
|
python = python3;
|
2022-04-04 18:30:41 +00:00
|
|
|
|
2022-09-11 19:55:12 +00:00
|
|
|
path = lib.makeBinPath [
|
|
|
|
ghostscript
|
2022-09-11 19:55:13 +00:00
|
|
|
imagemagickBig
|
2022-09-11 19:55:12 +00:00
|
|
|
jbig2enc
|
|
|
|
optipng
|
|
|
|
pngquant
|
|
|
|
qpdf
|
2022-09-21 13:34:42 +00:00
|
|
|
tesseract5
|
2022-09-11 19:55:12 +00:00
|
|
|
unpaper
|
2023-01-02 08:59:58 +00:00
|
|
|
poppler_utils
|
2022-09-11 19:55:12 +00:00
|
|
|
];
|
2023-01-29 22:59:57 +00:00
|
|
|
|
|
|
|
frontend = buildNpmPackage {
|
|
|
|
pname = "paperless-ngx-frontend";
|
|
|
|
inherit version src;
|
|
|
|
|
2023-12-06 22:35:40 +00:00
|
|
|
postPatch = ''
|
|
|
|
cd src-ui
|
|
|
|
'';
|
|
|
|
|
2023-12-28 12:20:08 +00:00
|
|
|
npmDepsHash = "sha256-o/inxHiOeMhQvZVcy6CM3Jy8B2sSp+8WJBknp3KVbZM=";
|
2023-01-29 22:59:57 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2023-12-06 22:35:40 +00:00
|
|
|
pkg-config
|
2023-01-29 22:59:57 +00:00
|
|
|
python3
|
2023-02-08 20:45:25 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
xcbuild
|
2023-01-29 22:59:57 +00:00
|
|
|
];
|
|
|
|
|
2023-12-06 22:35:40 +00:00
|
|
|
buildInputs = [
|
|
|
|
pango
|
|
|
|
];
|
2023-01-29 22:59:57 +00:00
|
|
|
|
|
|
|
CYPRESS_INSTALL_BINARY = "0";
|
|
|
|
NG_CLI_ANALYTICS = "false";
|
|
|
|
|
|
|
|
npmBuildFlags = [
|
|
|
|
"--" "--configuration" "production"
|
|
|
|
];
|
|
|
|
|
2023-06-22 18:16:50 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
npm run test
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2023-01-29 22:59:57 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/lib/paperless-ui
|
|
|
|
mv ../src/documents/static/frontend $out/lib/paperless-ui/
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
2022-04-04 18:30:41 +00:00
|
|
|
in
|
2023-01-29 22:59:57 +00:00
|
|
|
python.pkgs.buildPythonApplication rec {
|
2022-04-04 18:30:41 +00:00
|
|
|
pname = "paperless-ngx";
|
2023-01-29 22:59:57 +00:00
|
|
|
format = "other";
|
2022-04-04 18:30:41 +00:00
|
|
|
|
2023-01-29 22:59:57 +00:00
|
|
|
inherit version src;
|
2022-04-04 18:30:41 +00:00
|
|
|
|
2023-01-29 22:59:57 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
gettext
|
|
|
|
];
|
2022-04-04 18:30:41 +00:00
|
|
|
|
2023-01-29 22:59:57 +00:00
|
|
|
propagatedBuildInputs = with python.pkgs; [
|
2023-01-30 01:37:00 +00:00
|
|
|
amqp
|
|
|
|
anyio
|
2022-04-04 18:30:41 +00:00
|
|
|
asgiref
|
|
|
|
async-timeout
|
|
|
|
attrs
|
|
|
|
autobahn
|
|
|
|
automat
|
2023-01-30 01:37:00 +00:00
|
|
|
billiard
|
2023-01-07 23:15:47 +00:00
|
|
|
bleach
|
2022-12-19 10:30:44 +00:00
|
|
|
celery
|
2022-04-04 18:30:41 +00:00
|
|
|
certifi
|
|
|
|
cffi
|
|
|
|
channels-redis
|
|
|
|
channels
|
2023-01-30 01:37:00 +00:00
|
|
|
charset-normalizer
|
2022-04-04 18:30:41 +00:00
|
|
|
click
|
2023-01-30 01:37:00 +00:00
|
|
|
click-didyoumean
|
|
|
|
click-plugins
|
|
|
|
click-repl
|
2022-04-04 18:30:41 +00:00
|
|
|
coloredlogs
|
|
|
|
concurrent-log-handler
|
|
|
|
constantly
|
|
|
|
cryptography
|
|
|
|
dateparser
|
2023-11-29 20:08:10 +00:00
|
|
|
django-auditlog
|
2022-12-19 10:30:44 +00:00
|
|
|
django-celery-results
|
2023-02-27 18:28:45 +00:00
|
|
|
django-compression-middleware
|
2023-11-29 20:08:10 +00:00
|
|
|
django-cors-headers
|
2022-04-04 18:30:41 +00:00
|
|
|
django-extensions
|
|
|
|
django-filter
|
2023-04-15 08:39:27 +00:00
|
|
|
django-guardian
|
2023-11-29 20:08:10 +00:00
|
|
|
django-multiselectfield
|
2022-04-04 18:30:41 +00:00
|
|
|
django
|
2023-04-15 08:39:27 +00:00
|
|
|
djangorestframework-guardian2
|
2022-04-04 18:30:41 +00:00
|
|
|
djangorestframework
|
2023-11-29 20:08:10 +00:00
|
|
|
drf-writable-nested
|
2022-04-04 18:30:41 +00:00
|
|
|
filelock
|
2023-11-29 20:08:10 +00:00
|
|
|
flower
|
|
|
|
gotenberg-client
|
2022-04-04 18:30:41 +00:00
|
|
|
gunicorn
|
|
|
|
h11
|
2023-11-29 20:08:10 +00:00
|
|
|
h2
|
2022-04-04 18:30:41 +00:00
|
|
|
hiredis
|
|
|
|
httptools
|
2023-06-27 23:40:24 +00:00
|
|
|
httpx
|
2022-04-04 18:30:41 +00:00
|
|
|
humanfriendly
|
2023-01-30 01:37:00 +00:00
|
|
|
humanize
|
2022-04-04 18:30:41 +00:00
|
|
|
hyperlink
|
|
|
|
idna
|
|
|
|
imap-tools
|
|
|
|
img2pdf
|
|
|
|
incremental
|
|
|
|
inotify-simple
|
|
|
|
inotifyrecursive
|
|
|
|
joblib
|
|
|
|
langdetect
|
|
|
|
lxml
|
|
|
|
msgpack
|
2023-01-30 01:37:00 +00:00
|
|
|
mysqlclient
|
2023-01-07 23:15:47 +00:00
|
|
|
nltk
|
2022-04-04 18:30:41 +00:00
|
|
|
ocrmypdf
|
2023-01-30 01:37:00 +00:00
|
|
|
packaging
|
2022-04-04 18:30:41 +00:00
|
|
|
pathvalidate
|
2022-04-28 13:48:06 +00:00
|
|
|
pdf2image
|
2022-04-04 18:30:41 +00:00
|
|
|
pikepdf
|
|
|
|
pillow
|
|
|
|
pluggy
|
|
|
|
portalocker
|
2023-01-30 01:37:00 +00:00
|
|
|
prompt-toolkit
|
2022-04-04 18:30:41 +00:00
|
|
|
psycopg2
|
|
|
|
pyasn1-modules
|
|
|
|
pyasn1
|
|
|
|
pycparser
|
|
|
|
pyopenssl
|
|
|
|
python-dateutil
|
|
|
|
python-dotenv
|
2023-05-16 10:26:48 +00:00
|
|
|
python-ipware
|
2022-05-06 23:18:35 +00:00
|
|
|
python-magic
|
2023-11-29 20:08:10 +00:00
|
|
|
python-gnupg
|
2022-04-04 18:30:41 +00:00
|
|
|
pytz
|
|
|
|
pyyaml
|
2022-04-28 13:48:06 +00:00
|
|
|
pyzbar
|
2022-12-19 10:30:44 +00:00
|
|
|
rapidfuzz
|
2022-04-04 18:30:41 +00:00
|
|
|
redis
|
|
|
|
regex
|
|
|
|
reportlab
|
|
|
|
requests
|
|
|
|
scikit-learn
|
|
|
|
scipy
|
2023-01-30 01:37:00 +00:00
|
|
|
setproctitle
|
2023-11-29 20:08:10 +00:00
|
|
|
service-identity
|
2023-01-30 01:37:00 +00:00
|
|
|
sniffio
|
2022-04-04 18:30:41 +00:00
|
|
|
sqlparse
|
|
|
|
threadpoolctl
|
2023-05-16 10:26:48 +00:00
|
|
|
tika-client
|
2023-01-30 01:37:00 +00:00
|
|
|
tornado
|
2022-04-04 18:30:41 +00:00
|
|
|
tqdm
|
2023-01-30 01:37:00 +00:00
|
|
|
twisted
|
2022-04-04 18:30:41 +00:00
|
|
|
txaio
|
2023-01-30 01:37:00 +00:00
|
|
|
tzdata
|
2022-04-04 18:30:41 +00:00
|
|
|
tzlocal
|
|
|
|
urllib3
|
|
|
|
uvicorn
|
|
|
|
uvloop
|
2023-01-30 01:37:00 +00:00
|
|
|
vine
|
2022-04-04 18:30:41 +00:00
|
|
|
watchdog
|
2023-01-30 01:37:00 +00:00
|
|
|
watchfiles
|
2022-04-04 18:30:41 +00:00
|
|
|
wcwidth
|
2023-01-30 01:37:00 +00:00
|
|
|
webencodings
|
2022-04-04 18:30:41 +00:00
|
|
|
websockets
|
|
|
|
whitenoise
|
|
|
|
whoosh
|
2023-01-30 01:37:00 +00:00
|
|
|
zipp
|
2022-04-04 18:30:41 +00:00
|
|
|
zope_interface
|
2023-11-05 04:50:22 +00:00
|
|
|
zxing-cpp
|
2023-01-30 01:37:00 +00:00
|
|
|
]
|
|
|
|
++ redis.optional-dependencies.hiredis
|
|
|
|
++ twisted.optional-dependencies.tls
|
|
|
|
++ uvicorn.optional-dependencies.standard;
|
2023-01-29 22:59:57 +00:00
|
|
|
|
2022-04-04 18:30:41 +00:00
|
|
|
postBuild = ''
|
2023-01-29 22:59:57 +00:00
|
|
|
# Compile manually because `pythonRecompileBytecodeHook` only works
|
|
|
|
# for files in `python.sitePackages`
|
2023-11-06 01:38:24 +00:00
|
|
|
${python.pythonOnBuildForHost.interpreter} -OO -m compileall src
|
2023-01-29 22:59:57 +00:00
|
|
|
|
|
|
|
# Collect static files
|
2023-11-06 01:38:24 +00:00
|
|
|
${python.pythonOnBuildForHost.interpreter} src/manage.py collectstatic --clear --no-input
|
2023-01-29 22:59:57 +00:00
|
|
|
|
|
|
|
# Compile string translations using gettext
|
2023-11-06 01:38:24 +00:00
|
|
|
${python.pythonOnBuildForHost.interpreter} src/manage.py compilemessages
|
2022-04-04 18:30:41 +00:00
|
|
|
'';
|
|
|
|
|
2023-12-06 12:27:11 +00:00
|
|
|
installPhase = let
|
|
|
|
pythonPath = python.pkgs.makePythonPath propagatedBuildInputs;
|
|
|
|
in ''
|
2023-01-29 22:59:57 +00:00
|
|
|
mkdir -p $out/lib/paperless-ngx
|
|
|
|
cp -r {src,static,LICENSE,gunicorn.conf.py} $out/lib/paperless-ngx
|
|
|
|
ln -s ${frontend}/lib/paperless-ui/frontend $out/lib/paperless-ngx/static/
|
2022-04-04 18:30:41 +00:00
|
|
|
chmod +x $out/lib/paperless-ngx/src/manage.py
|
|
|
|
makeWrapper $out/lib/paperless-ngx/src/manage.py $out/bin/paperless-ngx \
|
2023-12-06 12:27:11 +00:00
|
|
|
--prefix PYTHONPATH : "${pythonPath}" \
|
2022-04-04 18:30:41 +00:00
|
|
|
--prefix PATH : "${path}"
|
2022-12-25 23:06:52 +00:00
|
|
|
makeWrapper ${python.pkgs.celery}/bin/celery $out/bin/celery \
|
2023-12-06 12:27:11 +00:00
|
|
|
--prefix PYTHONPATH : "${pythonPath}:$out/lib/paperless-ngx/src" \
|
2022-12-25 23:06:52 +00:00
|
|
|
--prefix PATH : "${path}"
|
2022-04-04 18:30:41 +00:00
|
|
|
'';
|
|
|
|
|
2023-01-30 17:52:21 +00:00
|
|
|
postFixup = ''
|
|
|
|
# Remove tests with samples (~14M)
|
|
|
|
find $out/lib/paperless-ngx -type d -name tests -exec rm -rv {} +
|
|
|
|
'';
|
|
|
|
|
2023-01-30 01:37:00 +00:00
|
|
|
nativeCheckInputs = with python.pkgs; [
|
2023-05-16 10:26:48 +00:00
|
|
|
daphne
|
2023-10-08 03:32:12 +00:00
|
|
|
factory-boy
|
2023-01-30 01:37:00 +00:00
|
|
|
imagehash
|
2022-04-04 18:30:41 +00:00
|
|
|
pytest-django
|
|
|
|
pytest-env
|
2023-05-16 10:26:48 +00:00
|
|
|
pytest-httpx
|
2023-08-25 09:19:08 +00:00
|
|
|
pytest-rerunfailures
|
2022-04-04 18:30:41 +00:00
|
|
|
pytest-xdist
|
|
|
|
pytestCheckHook
|
2023-05-16 10:26:48 +00:00
|
|
|
reportlab
|
2022-04-04 18:30:41 +00:00
|
|
|
];
|
|
|
|
|
2022-10-21 09:23:42 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"src"
|
|
|
|
];
|
2022-04-04 18:30:41 +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 \
|
2023-02-27 18:28:45 +00:00
|
|
|
--replace "--cov --cov-report=html --cov-report=xml" ""
|
2022-04-04 18:30:41 +00:00
|
|
|
'';
|
|
|
|
|
2022-12-19 10:30:44 +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-21 09:23:42 +00:00
|
|
|
|
2023-02-08 20:45:25 +00:00
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
|
2022-04-04 18:30:41 +00:00
|
|
|
passthru = {
|
2023-01-29 22:59:57 +00:00
|
|
|
inherit python path frontend;
|
2022-04-12 15:48:53 +00:00
|
|
|
tests = { inherit (nixosTests) paperless; };
|
2022-04-04 18:30:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
2022-10-21 09:23:42 +00:00
|
|
|
description = "Tool to scan, index, and archive all of your physical documents";
|
2023-02-12 15:31:50 +00:00
|
|
|
homepage = "https://docs.paperless-ngx.com/";
|
2023-01-30 01:37:00 +00:00
|
|
|
changelog = "https://github.com/paperless-ngx/paperless-ngx/releases/tag/v${version}";
|
2022-04-04 18:30:41 +00:00
|
|
|
license = licenses.gpl3Only;
|
2023-02-08 20:45:25 +00:00
|
|
|
platforms = platforms.unix;
|
2023-06-27 23:44:20 +00:00
|
|
|
maintainers = with maintainers; [ lukegb gador erikarvstedt leona ];
|
2022-04-04 18:30:41 +00:00
|
|
|
};
|
|
|
|
}
|