From 9ec889b4b81b5323afe0066a0b132fd2b4188cbe Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Mon, 2 Jan 2023 09:59:58 +0100 Subject: [PATCH 1/3] paperless-ngx: fix build missing poppler will result in pyTest failing Signed-off-by: Florian Brandes --- pkgs/applications/office/paperless-ngx/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/applications/office/paperless-ngx/default.nix b/pkgs/applications/office/paperless-ngx/default.nix index eaad04c64f6f..feda51e4f665 100644 --- a/pkgs/applications/office/paperless-ngx/default.nix +++ b/pkgs/applications/office/paperless-ngx/default.nix @@ -10,6 +10,7 @@ , qpdf , tesseract5 , unpaper +, poppler_utils , liberation_ttf , fetchFromGitHub }: @@ -75,6 +76,7 @@ let qpdf tesseract5 unpaper + poppler_utils ]; in python.pkgs.pythonPackages.buildPythonApplication rec { From 5b6881f4a0797cf7cc6c3350c4bc784a851e0124 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Mon, 2 Jan 2023 12:19:27 +0100 Subject: [PATCH 2/3] nixos/paperless-ngx: fix startup order The nixOS test failed sporadically with a timeout. This is due to a race condition in the startup of the scheduler vs the task-queue. The scheduler runs the migration scripts in "pre-start" and celery isn't available, yet. The celery worker (paperless-task-queue) was already started by systemd but was unable to connect (as the migration scripts from "pre-start" still ran). This fix adds the necessary "after" condition in the systemd worker unit and adds a test to "paperless" Signed-off-by: Florian Brandes --- nixos/modules/services/misc/paperless.nix | 1 + nixos/tests/paperless.nix | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index 33a8394dff2d..54c53a011343 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -258,6 +258,7 @@ in PrivateNetwork = false; }; environment = env; + after = [ "paperless-scheduler.service" ]; }; # Reading the user-provided password file requires root access diff --git a/nixos/tests/paperless.nix b/nixos/tests/paperless.nix index b97834835c2c..7f36de4c29b7 100644 --- a/nixos/tests/paperless.nix +++ b/nixos/tests/paperless.nix @@ -26,6 +26,10 @@ import ./make-test-python.nix ({ lib, ... }: { # Wait until server accepts connections machine.wait_until_succeeds("curl -fs localhost:28981") + # Required for consuming documents via the web interface + with subtest("Task-queue gets ready"): + machine.wait_for_unit("paperless-task-queue.service") + with subtest("Add a document via the web interface"): machine.succeed( "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black " From b406baead835cbc5e0bb4e316b89c8ddab2211fa Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Mon, 2 Jan 2023 15:22:37 +0100 Subject: [PATCH 3/3] nixos/paperless-ngx: reorder "after" keyword Signed-off-by: Florian Brandes --- nixos/modules/services/misc/paperless.nix | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index 54c53a011343..1dddd147ac09 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -212,14 +212,14 @@ in systemd.services.paperless-scheduler = { description = "Paperless Celery Beat"; + wantedBy = [ "multi-user.target" ]; + wants = [ "paperless-consumer.service" "paperless-web.service" "paperless-task-queue.service" ]; serviceConfig = defaultServiceConfig // { User = cfg.user; ExecStart = "${pkg}/bin/celery --app paperless beat --loglevel INFO"; Restart = "on-failure"; }; environment = env; - wantedBy = [ "multi-user.target" ]; - wants = [ "paperless-consumer.service" "paperless-web.service" "paperless-task-queue.service" ]; preStart = '' ln -sf ${manage} ${cfg.dataDir}/paperless-manage @@ -248,6 +248,7 @@ in systemd.services.paperless-task-queue = { description = "Paperless Celery Workers"; + after = [ "paperless-scheduler.service" ]; serviceConfig = defaultServiceConfig // { User = cfg.user; ExecStart = "${pkg}/bin/celery --app paperless worker --loglevel INFO"; @@ -258,7 +259,6 @@ in PrivateNetwork = false; }; environment = env; - after = [ "paperless-scheduler.service" ]; }; # Reading the user-provided password file requires root access @@ -276,20 +276,24 @@ in systemd.services.paperless-consumer = { description = "Paperless document consumer"; + # Bind to `paperless-scheduler` so that the consumer never runs + # during migrations + bindsTo = [ "paperless-scheduler.service" ]; + after = [ "paperless-scheduler.service" ]; serviceConfig = defaultServiceConfig // { User = cfg.user; ExecStart = "${pkg}/bin/paperless-ngx document_consumer"; Restart = "on-failure"; }; environment = env; - # Bind to `paperless-scheduler` so that the consumer never runs - # during migrations - bindsTo = [ "paperless-scheduler.service" ]; - after = [ "paperless-scheduler.service" ]; }; systemd.services.paperless-web = { description = "Paperless web server"; + # Bind to `paperless-scheduler` so that the web server never runs + # during migrations + bindsTo = [ "paperless-scheduler.service" ]; + after = [ "paperless-scheduler.service" ]; serviceConfig = defaultServiceConfig // { User = cfg.user; ExecStart = '' @@ -313,10 +317,6 @@ 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-task-queue.service"; - # Bind to `paperless-scheduler` so that the web server never runs - # during migrations - bindsTo = [ "paperless-scheduler.service" ]; - after = [ "paperless-scheduler.service" ]; }; users = optionalAttrs (cfg.user == defaultUser) {