about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorErik Arvstedt <erik.arvstedt@gmail.com>2022-09-05 10:03:59 +0200
committerErik Arvstedt <erik.arvstedt@gmail.com>2022-09-05 10:03:59 +0200
commit310b9fe58d34a4d655778bf561e8fb021e2d4b70 (patch)
treec7f2c498aeb08cdab7c2326e7be0f262d3a98983 /nixos
parent2f8b455b00866a121bf075bb9c61908a118ec63a (diff)
downloadnixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.tar
nixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.tar.gz
nixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.tar.bz2
nixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.tar.lz
nixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.tar.xz
nixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.tar.zst
nixlib-310b9fe58d34a4d655778bf561e8fb021e2d4b70.zip
nixos/paperless: extract variable `pkg`
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/paperless.nix21
1 files changed, 11 insertions, 10 deletions
diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix
index b1cf72258d17..c29824ee8345 100644
--- a/nixos/modules/services/misc/paperless.nix
+++ b/nixos/modules/services/misc/paperless.nix
@@ -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.pythonPath}:${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.