{ stdenv , lib , fetchFromGitHub , makeWrapper , callPackage , python3 , imagemagick7 , ghostscript , optipng , tesseract , unpaper }: ## Usage # ${paperless}/bin/paperless wraps manage.py # ${paperless}/share/paperless/setup-env.sh can be sourced from a # shell script to setup a Paperless environment # paperless.withConfig is a convenience function to setup a # configured Paperless instance. (See ./withConfig.nix) # For WSGI with gunicorn, use a shell script like this: # let # pythonEnv = paperless.python.withPackages (ps: paperless.runtimePackages ++ [ ps.gunicorn ]); # in # writers.writeBash "run-gunicorn" '' # source ${paperless}/share/paperless/setup-env.sh # PYTHONPATH=$paperlessSrc ${pythonEnv}/bin/gunicorn paperless.wsgi # '' let paperless = stdenv.mkDerivation rec { pname = "paperless"; version = "2.7.0"; src = fetchFromGitHub { owner = "the-paperless-project"; repo = "paperless"; rev = version; sha256 = "0pkmyky1crjnsg7r0gfk0fadisfsgzlsq6afpz16wx4hp6yvkkf7"; }; nativeBuildInputs = [ makeWrapper ]; doCheck = true; dontInstall = true; pythonEnv = python.withPackages (_: runtimePackages); pythonCheckEnv = python.withPackages (_: (runtimePackages ++ checkPackages)); unpackPhase = '' srcDir=$out/share/paperless mkdir -p $srcDir cp -r --no-preserve=mode $src/src/* $src/LICENSE $srcDir ''; buildPhase = let # Paperless has explicit runtime checks that expect these binaries to be in PATH extraBin = lib.makeBinPath [ imagemagick7 ghostscript optipng tesseract unpaper ]; in '' ${python.interpreter} -m compileall $srcDir makeWrapper $pythonEnv/bin/python $out/bin/paperless \ --set PATH ${extraBin} --add-flags $out/share/paperless/manage.py # A shell snippet that can be sourced to setup a paperless env cat > $out/share/paperless/setup-env.sh <