diff --git a/nixos/modules/services/misc/paperless.nix b/nixos/modules/services/misc/paperless.nix index fbf1338a0dff..b1cf72258d17 100644 --- a/nixos/modules/services/misc/paperless.nix +++ b/nixos/modules/services/misc/paperless.nix @@ -17,9 +17,11 @@ let GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port}"; } // ( lib.mapAttrs (_: toString) cfg.extraConfig - ) // (optionalAttrs enableRedis { + ) // optionalAttrs (config.time.timeZone != null) { + PAPERLESS_TIME_ZONE = lib.mkDefault config.time.timeZone; + } // optionalAttrs enableRedis { PAPERLESS_REDIS = "unix://${redisServer.unixSocket}"; - }); + }; manage = let setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env); @@ -174,11 +176,10 @@ in See [the documentation](https://paperless-ngx.readthedocs.io/en/latest/configuration.html) for available options. ''; - example = literalExpression '' - { - PAPERLESS_OCR_LANGUAGE = "deu+eng"; - } - ''; + example = { + PAPERLESS_OCR_LANGUAGE = "deu+eng"; + PAPERLESS_DBHOST = "/run/postgresql"; + }; }; user = mkOption { @@ -285,12 +286,13 @@ in ''; Restart = "on-failure"; - AmbientCapabilities = "CAP_NET_BIND_SERVICE"; - CapabilityBoundingSet = "CAP_NET_BIND_SERVICE"; - # gunicorn needs setuid - SystemCallFilter = defaultServiceConfig.SystemCallFilter ++ [ "@setuid" ]; + # gunicorn needs setuid, liblapack needs mbind + SystemCallFilter = defaultServiceConfig.SystemCallFilter ++ [ "@setuid mbind" ]; # Needs to serve web page PrivateNetwork = false; + } // lib.optionalAttrs (cfg.port < 1024) { + AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; + CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ]; }; environment = env // { PATH = mkForce cfg.package.path; diff --git a/pkgs/applications/office/paperless-ngx/default.nix b/pkgs/applications/office/paperless-ngx/default.nix index 679a732c2d67..a42ec844d115 100644 --- a/pkgs/applications/office/paperless-ngx/default.nix +++ b/pkgs/applications/office/paperless-ngx/default.nix @@ -16,7 +16,7 @@ let # Use specific package versions required by paperless-ngx - py = python3.override { + python = python3.override { packageOverrides = self: super: { django = super.django_4; @@ -51,7 +51,7 @@ let path = lib.makeBinPath [ ghostscript imagemagick jbig2enc optipng pngquant qpdf tesseract4 unpaper ]; in -py.pkgs.pythonPackages.buildPythonApplication rec { +python.pkgs.pythonPackages.buildPythonApplication rec { pname = "paperless-ngx"; version = "1.8.0"; @@ -63,7 +63,7 @@ py.pkgs.pythonPackages.buildPythonApplication rec { format = "other"; - propagatedBuildInputs = with py.pkgs.pythonPackages; [ + propagatedBuildInputs = with python.pkgs.pythonPackages; [ aioredis arrow asgiref @@ -169,7 +169,7 @@ py.pkgs.pythonPackages.buildPythonApplication rec { # Compile manually because `pythonRecompileBytecodeHook` only works for # files in `python.sitePackages` postBuild = '' - ${py.interpreter} -OO -m compileall src + ${python.interpreter} -OO -m compileall src ''; installPhase = '' @@ -181,7 +181,7 @@ py.pkgs.pythonPackages.buildPythonApplication rec { --prefix PATH : "${path}" ''; - checkInputs = with py.pkgs.pythonPackages; [ + checkInputs = with python.pkgs.pythonPackages; [ pytest-django pytest-env pytest-sugar @@ -207,6 +207,7 @@ py.pkgs.pythonPackages.buildPythonApplication rec { ''; passthru = { + inherit python; # PYTHONPATH of all dependencies used by the package pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs; inherit path;