From bfad8cd5e0c52e2c8db7dab6a843c8d0f0e89f59 Mon Sep 17 00:00:00 2001 From: Leona Maroni Date: Sun, 25 Dec 2022 23:06:52 +0000 Subject: [PATCH 1/2] paperless-ngx: add celery wrapper --- pkgs/applications/office/paperless-ngx/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/applications/office/paperless-ngx/default.nix b/pkgs/applications/office/paperless-ngx/default.nix index c31436edef8c..eaad04c64f6f 100644 --- a/pkgs/applications/office/paperless-ngx/default.nix +++ b/pkgs/applications/office/paperless-ngx/default.nix @@ -200,6 +200,9 @@ python.pkgs.pythonPackages.buildPythonApplication rec { makeWrapper $out/lib/paperless-ngx/src/manage.py $out/bin/paperless-ngx \ --prefix PYTHONPATH : "$PYTHONPATH" \ --prefix PATH : "${path}" + makeWrapper ${python.pkgs.celery}/bin/celery $out/bin/celery \ + --prefix PYTHONPATH : "$PYTHONPATH:$out/lib/paperless-ngx/src" \ + --prefix PATH : "${path}" ''; checkInputs = with python.pkgs.pythonPackages; [ From 2d7b8ef56f960645cf4833426e354ac90e3b4c45 Mon Sep 17 00:00:00 2001 From: Leona Maroni Date: Sun, 25 Dec 2022 23:07:17 +0000 Subject: [PATCH 2/2] nixos/paperless: update for paperless-ngx 1.10.2 --- nixos/modules/services/misc/paperless.nix | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index 6a98d5cb686d..33a8394dff2d 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -211,19 +211,15 @@ in ]; systemd.services.paperless-scheduler = { - description = "Paperless scheduler"; + description = "Paperless Celery Beat"; serviceConfig = defaultServiceConfig // { User = cfg.user; - ExecStart = "${pkg}/bin/paperless-ngx qcluster"; + ExecStart = "${pkg}/bin/celery --app paperless beat --loglevel INFO"; Restart = "on-failure"; - # The `mbind` syscall is needed for running the classifier. - SystemCallFilter = defaultServiceConfig.SystemCallFilter ++ [ "mbind" ]; - # Needs to talk to mail server for automated import rules - PrivateNetwork = false; }; environment = env; wantedBy = [ "multi-user.target" ]; - wants = [ "paperless-consumer.service" "paperless-web.service" ]; + wants = [ "paperless-consumer.service" "paperless-web.service" "paperless-task-queue.service" ]; preStart = '' ln -sf ${manage} ${cfg.dataDir}/paperless-manage @@ -250,6 +246,20 @@ in after = [ "redis-paperless.service" ]; }; + systemd.services.paperless-task-queue = { + description = "Paperless Celery Workers"; + serviceConfig = defaultServiceConfig // { + User = cfg.user; + ExecStart = "${pkg}/bin/celery --app paperless worker --loglevel INFO"; + Restart = "on-failure"; + # The `mbind` syscall is needed for running the classifier. + SystemCallFilter = defaultServiceConfig.SystemCallFilter ++ [ "mbind" ]; + # Needs to talk to mail server for automated import rules + PrivateNetwork = false; + }; + environment = env; + }; + # Reading the user-provided password file requires root access systemd.services.paperless-copy-password = mkIf (cfg.passwordFile != null) { requiredBy = [ "paperless-scheduler.service" ]; @@ -301,7 +311,7 @@ in }; # Allow the web interface to access the private /tmp directory of the server. # This is required to support uploading files via the web interface. - unitConfig.JoinsNamespaceOf = "paperless-scheduler.service"; + unitConfig.JoinsNamespaceOf = "paperless-task-queue.service"; # Bind to `paperless-scheduler` so that the web server never runs # during migrations bindsTo = [ "paperless-scheduler.service" ];