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