nixpkgs/pkgs/applications/office/paperless-ngx/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

308 lines
6.1 KiB
Nix
Raw Normal View History

2022-04-04 18:30:41 +00:00
{ lib
2023-02-08 20:45:25 +00:00
, stdenv
, fetchFromGitHub
, buildNpmPackage
2022-04-04 18:30:41 +00:00
, nixosTests
, gettext
2022-04-04 18:30:41 +00:00
, python3
, ghostscript
, imagemagickBig
2022-04-04 18:30:41 +00:00
, jbig2enc
, optipng
, pngquant
, qpdf
, tesseract5
2022-04-04 18:30:41 +00:00
, unpaper
, 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
version = "2.2.1";
src = fetchFromGitHub {
owner = "paperless-ngx";
repo = "paperless-ngx";
rev = "refs/tags/v${version}";
hash = "sha256-ds/hQ0+poUTO2bnXiHvNUanVFJcxxyuW3a9Yxcq5cAg=";
};
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
imagemagickBig
2022-09-11 19:55:12 +00:00
jbig2enc
optipng
pngquant
qpdf
tesseract5
2022-09-11 19:55:12 +00:00
unpaper
poppler_utils
2022-09-11 19:55:12 +00:00
];
frontend = buildNpmPackage {
pname = "paperless-ngx-frontend";
inherit version src;
2023-12-06 22:35:40 +00:00
postPatch = ''
cd src-ui
'';
npmDepsHash = "sha256-o/inxHiOeMhQvZVcy6CM3Jy8B2sSp+8WJBknp3KVbZM=";
nativeBuildInputs = [
2023-12-06 22:35:40 +00:00
pkg-config
python3
2023-02-08 20:45:25 +00:00
] ++ lib.optionals stdenv.isDarwin [
xcbuild
];
2023-12-06 22:35:40 +00:00
buildInputs = [
pango
];
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
'';
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
python.pkgs.buildPythonApplication rec {
2022-04-04 18:30:41 +00:00
pname = "paperless-ngx";
format = "other";
2022-04-04 18:30:41 +00:00
inherit version src;
2022-04-04 18:30:41 +00:00
nativeBuildInputs = [
gettext
];
2022-04-04 18:30:41 +00:00
propagatedBuildInputs = with python.pkgs; [
amqp
anyio
2022-04-04 18:30:41 +00:00
asgiref
async-timeout
attrs
autobahn
automat
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
charset-normalizer
2022-04-04 18:30:41 +00:00
click
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
django-guardian
2023-11-29 20:08:10 +00:00
django-multiselectfield
2022-04-04 18:30:41 +00:00
django
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
humanize
2022-04-04 18:30:41 +00:00
hyperlink
idna
imap-tools
img2pdf
incremental
inotify-simple
inotifyrecursive
joblib
langdetect
lxml
msgpack
mysqlclient
2023-01-07 23:15:47 +00:00
nltk
2022-04-04 18:30:41 +00:00
ocrmypdf
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
prompt-toolkit
2022-04-04 18:30:41 +00:00
psycopg2
pyasn1-modules
pyasn1
pycparser
pyopenssl
python-dateutil
python-dotenv
python-ipware
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
setproctitle
2023-11-29 20:08:10 +00:00
service-identity
sniffio
2022-04-04 18:30:41 +00:00
sqlparse
threadpoolctl
tika-client
tornado
2022-04-04 18:30:41 +00:00
tqdm
twisted
2022-04-04 18:30:41 +00:00
txaio
tzdata
2022-04-04 18:30:41 +00:00
tzlocal
urllib3
uvicorn
uvloop
vine
2022-04-04 18:30:41 +00:00
watchdog
watchfiles
2022-04-04 18:30:41 +00:00
wcwidth
webencodings
2022-04-04 18:30:41 +00:00
websockets
whitenoise
whoosh
zipp
2022-04-04 18:30:41 +00:00
zope_interface
zxing-cpp
]
++ redis.optional-dependencies.hiredis
++ twisted.optional-dependencies.tls
++ uvicorn.optional-dependencies.standard;
2022-04-04 18:30:41 +00:00
postBuild = ''
# Compile manually because `pythonRecompileBytecodeHook` only works
# for files in `python.sitePackages`
${python.pythonOnBuildForHost.interpreter} -OO -m compileall src
# Collect static files
${python.pythonOnBuildForHost.interpreter} src/manage.py collectstatic --clear --no-input
# Compile string translations using gettext
${python.pythonOnBuildForHost.interpreter} src/manage.py compilemessages
2022-04-04 18:30:41 +00:00
'';
installPhase = let
pythonPath = python.pkgs.makePythonPath propagatedBuildInputs;
in ''
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 \
--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 \
--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
'';
postFixup = ''
# Remove tests with samples (~14M)
find $out/lib/paperless-ngx -type d -name tests -exec rm -rv {} +
'';
nativeCheckInputs = with python.pkgs; [
daphne
factory-boy
imagehash
2022-04-04 18:30:41 +00:00
pytest-django
pytest-env
pytest-httpx
2023-08-25 09:19:08 +00:00
pytest-rerunfailures
2022-04-04 18:30:41 +00:00
pytest-xdist
pytestCheckHook
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 = {
inherit python path frontend;
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/";
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
};
}