Merge pull request from erikarvstedt/paperless-pythonpath

This commit is contained in:
Martin Weinelt 2022-09-05 15:26:20 +02:00 committed by GitHub
commit 268569b6d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions
nixos/modules/services/misc
pkgs/applications/office/paperless-ngx

View file

@ -3,6 +3,7 @@
with lib;
let
cfg = config.services.paperless;
pkg = cfg.package;
defaultUser = "paperless";
@ -27,7 +28,7 @@ let
setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env);
in pkgs.writeShellScript "manage" ''
${setupEnv}
exec ${cfg.package}/bin/paperless-ngx "$@"
exec ${pkg}/bin/paperless-ngx "$@"
'';
# Secure the services
@ -213,7 +214,7 @@ in
description = "Paperless scheduler";
serviceConfig = defaultServiceConfig // {
User = cfg.user;
ExecStart = "${cfg.package}/bin/paperless-ngx qcluster";
ExecStart = "${pkg}/bin/paperless-ngx qcluster";
Restart = "on-failure";
# The `mbind` syscall is needed for running the classifier.
SystemCallFilter = defaultServiceConfig.SystemCallFilter ++ [ "mbind" ];
@ -229,9 +230,9 @@ in
# Auto-migrate on first run or if the package has changed
versionFile="${cfg.dataDir}/src-version"
if [[ $(cat "$versionFile" 2>/dev/null) != ${cfg.package} ]]; then
${cfg.package}/bin/paperless-ngx migrate
echo ${cfg.package} > "$versionFile"
if [[ $(cat "$versionFile" 2>/dev/null) != ${pkg} ]]; then
${pkg}/bin/paperless-ngx migrate
echo ${pkg} > "$versionFile"
fi
''
+ optionalString (cfg.passwordFile != null) ''
@ -241,7 +242,7 @@ in
superuserStateFile="${cfg.dataDir}/superuser-state"
if [[ $(cat "$superuserStateFile" 2>/dev/null) != $superuserState ]]; then
${cfg.package}/bin/paperless-ngx manage_superuser
${pkg}/bin/paperless-ngx manage_superuser
echo "$superuserState" > "$superuserStateFile"
fi
'';
@ -266,7 +267,7 @@ in
description = "Paperless document consumer";
serviceConfig = defaultServiceConfig // {
User = cfg.user;
ExecStart = "${cfg.package}/bin/paperless-ngx document_consumer";
ExecStart = "${pkg}/bin/paperless-ngx document_consumer";
Restart = "on-failure";
};
environment = env;
@ -282,7 +283,7 @@ in
User = cfg.user;
ExecStart = ''
${pkgs.python3Packages.gunicorn}/bin/gunicorn \
-c ${cfg.package}/lib/paperless-ngx/gunicorn.conf.py paperless.asgi:application
-c ${pkg}/lib/paperless-ngx/gunicorn.conf.py paperless.asgi:application
'';
Restart = "on-failure";
@ -295,8 +296,8 @@ in
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
};
environment = env // {
PATH = mkForce cfg.package.path;
PYTHONPATH = "${cfg.package.pythonPath}:${cfg.package}/lib/paperless-ngx/src";
PATH = mkForce pkg.path;
PYTHONPATH = "${pkg.python.pkgs.makePythonPath pkg.propagatedBuildInputs}:${pkg}/lib/paperless-ngx/src";
};
# Allow the web interface to access the private /tmp directory of the server.
# This is required to support uploading files via the web interface.

View file

@ -207,11 +207,7 @@ python.pkgs.pythonPackages.buildPythonApplication rec {
'';
passthru = {
inherit python;
# PYTHONPATH of all dependencies used by the package
pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs;
inherit path;
inherit python path;
tests = { inherit (nixosTests) paperless; };
};