2021-08-18 13:19:15 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
2022-04-15 01:41:22 +00:00
|
|
|
cfg = config.services.paperless;
|
2022-09-09 14:08:57 +00:00
|
|
|
pkg = cfg.package;
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
defaultUser = "paperless";
|
2023-08-10 07:59:29 +00:00
|
|
|
defaultFont = "${pkgs.liberation_ttf}/share/fonts/truetype/LiberationSerif-Regular.ttf";
|
2021-08-18 13:19:15 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Don't start a redis instance if the user sets a custom redis connection
|
2024-01-13 08:15:51 +00:00
|
|
|
enableRedis = !(cfg.settings ? PAPERLESS_REDIS);
|
2022-04-15 01:41:22 +00:00
|
|
|
redisServer = config.services.redis.servers.paperless;
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2021-08-18 13:19:15 +00:00
|
|
|
env = {
|
|
|
|
PAPERLESS_DATA_DIR = cfg.dataDir;
|
|
|
|
PAPERLESS_MEDIA_ROOT = cfg.mediaDir;
|
|
|
|
PAPERLESS_CONSUMPTION_DIR = cfg.consumptionDir;
|
2023-08-10 07:59:29 +00:00
|
|
|
PAPERLESS_THUMBNAIL_FONT_NAME = defaultFont;
|
2021-08-18 13:19:15 +00:00
|
|
|
GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port}";
|
2022-09-10 19:16:41 +00:00
|
|
|
} // optionalAttrs (config.time.timeZone != null) {
|
|
|
|
PAPERLESS_TIME_ZONE = config.time.timeZone;
|
2022-09-14 18:05:37 +00:00
|
|
|
} // optionalAttrs enableRedis {
|
|
|
|
PAPERLESS_REDIS = "unix://${redisServer.unixSocket}";
|
2024-02-07 01:22:34 +00:00
|
|
|
} // optionalAttrs (cfg.settings.PAPERLESS_ENABLE_NLTK or true) {
|
|
|
|
PAPERLESS_NLTK_DIR = pkgs.symlinkJoin {
|
|
|
|
name = "paperless_ngx_nltk_data";
|
|
|
|
paths = pkg.nltkData;
|
|
|
|
};
|
2024-01-13 08:15:51 +00:00
|
|
|
} // (lib.mapAttrs (_: s:
|
|
|
|
if (lib.isAttrs s || lib.isList s) then builtins.toJSON s
|
|
|
|
else if lib.isBool s then lib.boolToString s
|
|
|
|
else toString s
|
|
|
|
) cfg.settings);
|
2021-08-18 13:19:15 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
manage = pkgs.writeShellScript "manage" ''
|
|
|
|
set -o allexport # Export the following env vars
|
|
|
|
${lib.toShellVars env}
|
|
|
|
exec ${pkg}/bin/paperless-ngx "$@"
|
|
|
|
'';
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
# Secure the services
|
|
|
|
defaultServiceConfig = {
|
2023-10-19 13:55:26 +00:00
|
|
|
ReadWritePaths = [
|
2021-08-18 13:19:15 +00:00
|
|
|
cfg.consumptionDir
|
|
|
|
cfg.dataDir
|
|
|
|
cfg.mediaDir
|
|
|
|
];
|
2023-03-04 12:14:45 +00:00
|
|
|
CacheDirectory = "paperless";
|
2021-08-18 13:19:15 +00:00
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
# ProtectClock adds DeviceAllow=char-rtc r
|
|
|
|
DeviceAllow = "";
|
|
|
|
LockPersonality = true;
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateMounts = true;
|
2022-02-20 05:27:41 +00:00
|
|
|
PrivateNetwork = true;
|
2021-08-18 13:19:15 +00:00
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
# Breaks if the home dir of the user is in /home
|
|
|
|
# ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
2023-10-19 13:55:26 +00:00
|
|
|
ProtectSystem = "strict";
|
2021-08-18 13:19:15 +00:00
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectProc = "invisible";
|
2022-04-15 01:41:22 +00:00
|
|
|
# Don't restrict ProcSubset because django-q requires read access to /proc/stat
|
|
|
|
# to query CPU and memory information.
|
|
|
|
# Note that /proc only contains processes of user `paperless`, so this is safe.
|
|
|
|
# ProcSubset = "pid";
|
2021-08-25 08:27:29 +00:00
|
|
|
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
|
2021-08-18 13:19:15 +00:00
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
2022-04-15 01:41:22 +00:00
|
|
|
SupplementaryGroups = optional enableRedis redisServer.user;
|
2021-08-18 13:19:15 +00:00
|
|
|
SystemCallArchitectures = "native";
|
2022-09-30 11:47:45 +00:00
|
|
|
SystemCallFilter = [ "@system-service" "~@privileged @setuid @keyring" ];
|
2023-07-15 17:15:38 +00:00
|
|
|
UMask = "0066";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2023-07-15 17:15:38 +00:00
|
|
|
meta.maintainers = with maintainers; [ erikarvstedt Flakebi leona ];
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
imports = [
|
2022-04-15 01:41:22 +00:00
|
|
|
(mkRenamedOptionModule [ "services" "paperless-ng" ] [ "services" "paperless" ])
|
2024-01-13 08:15:51 +00:00
|
|
|
(mkRenamedOptionModule [ "services" "paperless" "extraConfig" ] [ "services" "paperless" "settings" ])
|
2021-08-18 13:19:15 +00:00
|
|
|
];
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
options.services.paperless = {
|
2021-08-18 13:19:15 +00:00
|
|
|
enable = mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-15 01:41:22 +00:00
|
|
|
Enable Paperless.
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
When started, the Paperless database is automatically created if it doesn't
|
|
|
|
exist and updated if the Paperless package has changed.
|
|
|
|
Both tasks are achieved by running a Django migration.
|
|
|
|
|
|
|
|
A script to manage the Paperless instance (by wrapping Django's manage.py) is linked to
|
2022-08-12 12:06:08 +00:00
|
|
|
`''${dataDir}/paperless-manage`.
|
2021-08-18 13:19:15 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/paperless";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Directory to store the Paperless data.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
mediaDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${cfg.dataDir}/media";
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression ''"''${dataDir}/media"'';
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Directory to store the Paperless documents.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
consumptionDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${cfg.dataDir}/consume";
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression ''"''${dataDir}/consume"'';
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Directory from which new documents are imported.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
consumptionDirIsPublic = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Whether all users can write to the consumption dir.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
passwordFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2022-04-15 01:41:22 +00:00
|
|
|
example = "/run/keys/paperless-password";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-08-18 13:19:15 +00:00
|
|
|
A file containing the superuser password.
|
|
|
|
|
|
|
|
A superuser is required to access the web interface.
|
|
|
|
If unset, you can create a superuser manually by running
|
2022-08-12 12:06:08 +00:00
|
|
|
`''${dataDir}/paperless-manage createsuperuser`.
|
2021-08-18 13:19:15 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
The default superuser name is `admin`. To change it, set
|
2024-02-07 01:22:34 +00:00
|
|
|
option {option}`settings.PAPERLESS_ADMIN_USER`.
|
2021-08-18 13:19:15 +00:00
|
|
|
WARNING: When changing the superuser name after the initial setup, the old superuser
|
|
|
|
will continue to exist.
|
|
|
|
|
|
|
|
To disable login for the web interface, set the following:
|
2024-02-07 01:22:34 +00:00
|
|
|
`settings.PAPERLESS_AUTO_LOGIN_USERNAME = "admin";`.
|
2021-08-18 13:19:15 +00:00
|
|
|
WARNING: Only use this on a trusted system without internet access to Paperless.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "localhost";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Web interface address.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 28981;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Web interface port.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
settings = mkOption {
|
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = with lib.types; attrsOf (let
|
|
|
|
typeList = [ bool float int str path package ];
|
|
|
|
in oneOf (typeList ++ [ (listOf (oneOf typeList)) (attrsOf (oneOf typeList)) ]));
|
|
|
|
};
|
2023-03-04 12:14:45 +00:00
|
|
|
default = { };
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-15 01:41:22 +00:00
|
|
|
Extra paperless config options.
|
2021-08-18 13:19:15 +00:00
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
See [the documentation](https://docs.paperless-ngx.com/configuration/) for available options.
|
2023-08-04 22:07:22 +00:00
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
Note that some settings such as `PAPERLESS_CONSUMER_IGNORE_PATTERN` expect JSON values.
|
|
|
|
Settings declared as lists or attrsets will automatically be serialised into JSON strings for your convenience.
|
2023-08-04 22:07:22 +00:00
|
|
|
'';
|
2024-01-13 08:15:51 +00:00
|
|
|
example = {
|
|
|
|
PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
|
|
|
PAPERLESS_DBHOST = "/run/postgresql";
|
|
|
|
PAPERLESS_CONSUMER_IGNORE_PATTERN = [ ".DS_STORE/*" "desktop.ini" ];
|
|
|
|
PAPERLESS_OCR_USER_ARGS = {
|
|
|
|
optimize = 1;
|
|
|
|
pdfa_image_compression = "lossless";
|
2023-08-04 22:07:22 +00:00
|
|
|
};
|
2024-01-13 08:15:51 +00:00
|
|
|
};
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = defaultUser;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "User under which Paperless runs.";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "paperless-ngx" { };
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2022-04-15 01:41:22 +00:00
|
|
|
services.redis.servers.paperless.enable = mkIf enableRedis true;
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' - ${cfg.user} ${config.users.users.${cfg.user}.group} - -"
|
|
|
|
"d '${cfg.mediaDir}' - ${cfg.user} ${config.users.users.${cfg.user}.group} - -"
|
|
|
|
(if cfg.consumptionDirIsPublic then
|
|
|
|
"d '${cfg.consumptionDir}' 777 - - - -"
|
|
|
|
else
|
|
|
|
"d '${cfg.consumptionDir}' - ${cfg.user} ${config.users.users.${cfg.user}.group} - -"
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
systemd.services.paperless-scheduler = {
|
2022-12-28 21:21:41 +00:00
|
|
|
description = "Paperless Celery Beat";
|
2023-01-11 07:51:40 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "paperless-consumer.service" "paperless-web.service" "paperless-task-queue.service" ];
|
2021-08-18 13:19:15 +00:00
|
|
|
serviceConfig = defaultServiceConfig // {
|
|
|
|
User = cfg.user;
|
2022-12-28 21:21:41 +00:00
|
|
|
ExecStart = "${pkg}/bin/celery --app paperless beat --loglevel INFO";
|
2021-08-18 13:19:15 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
environment = env;
|
|
|
|
|
|
|
|
preStart = ''
|
2022-04-15 01:41:22 +00:00
|
|
|
ln -sf ${manage} ${cfg.dataDir}/paperless-manage
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
# Auto-migrate on first run or if the package has changed
|
|
|
|
versionFile="${cfg.dataDir}/src-version"
|
2023-02-02 18:25:31 +00:00
|
|
|
version=$(cat "$versionFile" 2>/dev/null || echo 0)
|
|
|
|
|
|
|
|
if [[ $version != ${pkg.version} ]]; then
|
2022-09-09 14:08:57 +00:00
|
|
|
${pkg}/bin/paperless-ngx migrate
|
2023-02-02 18:25:31 +00:00
|
|
|
|
|
|
|
# Parse old version string format for backwards compatibility
|
|
|
|
version=$(echo "$version" | grep -ohP '[^-]+$')
|
|
|
|
|
|
|
|
versionLessThan() {
|
|
|
|
target=$1
|
|
|
|
[[ $({ echo "$version"; echo "$target"; } | sort -V | head -1) != "$target" ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
if versionLessThan 1.12.0; then
|
|
|
|
# Reindex documents as mentioned in https://github.com/paperless-ngx/paperless-ngx/releases/tag/v1.12.1
|
|
|
|
echo "Reindexing documents, to allow searching old comments. Required after the 1.12.x upgrade."
|
|
|
|
${pkg}/bin/paperless-ngx document_index reindex
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ${pkg.version} > "$versionFile"
|
2021-08-18 13:19:15 +00:00
|
|
|
fi
|
|
|
|
''
|
|
|
|
+ optionalString (cfg.passwordFile != null) ''
|
|
|
|
export PAPERLESS_ADMIN_USER="''${PAPERLESS_ADMIN_USER:-admin}"
|
|
|
|
export PAPERLESS_ADMIN_PASSWORD=$(cat "${cfg.dataDir}/superuser-password")
|
|
|
|
superuserState="$PAPERLESS_ADMIN_USER:$PAPERLESS_ADMIN_PASSWORD"
|
|
|
|
superuserStateFile="${cfg.dataDir}/superuser-state"
|
|
|
|
|
|
|
|
if [[ $(cat "$superuserStateFile" 2>/dev/null) != $superuserState ]]; then
|
2022-09-09 14:08:57 +00:00
|
|
|
${pkg}/bin/paperless-ngx manage_superuser
|
2021-08-18 13:19:15 +00:00
|
|
|
echo "$superuserState" > "$superuserStateFile"
|
|
|
|
fi
|
|
|
|
'';
|
2022-04-15 01:41:22 +00:00
|
|
|
} // optionalAttrs enableRedis {
|
|
|
|
after = [ "redis-paperless.service" ];
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
systemd.services.paperless-task-queue = {
|
|
|
|
description = "Paperless Celery Workers";
|
2023-01-11 07:51:40 +00:00
|
|
|
after = [ "paperless-scheduler.service" ];
|
2022-12-28 21:21:41 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Reading the user-provided password file requires root access
|
|
|
|
systemd.services.paperless-copy-password = mkIf (cfg.passwordFile != null) {
|
|
|
|
requiredBy = [ "paperless-scheduler.service" ];
|
|
|
|
before = [ "paperless-scheduler.service" ];
|
2021-08-18 13:19:15 +00:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.coreutils}/bin/install --mode 600 --owner '${cfg.user}' --compare \
|
|
|
|
'${cfg.passwordFile}' '${cfg.dataDir}/superuser-password'
|
|
|
|
'';
|
|
|
|
Type = "oneshot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
systemd.services.paperless-consumer = {
|
2021-08-18 13:19:15 +00:00
|
|
|
description = "Paperless document consumer";
|
2023-01-11 07:51:40 +00:00
|
|
|
# Bind to `paperless-scheduler` so that the consumer never runs
|
|
|
|
# during migrations
|
|
|
|
bindsTo = [ "paperless-scheduler.service" ];
|
|
|
|
after = [ "paperless-scheduler.service" ];
|
2021-08-18 13:19:15 +00:00
|
|
|
serviceConfig = defaultServiceConfig // {
|
|
|
|
User = cfg.user;
|
2022-09-09 14:08:57 +00:00
|
|
|
ExecStart = "${pkg}/bin/paperless-ngx document_consumer";
|
2021-08-18 13:19:15 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
environment = env;
|
2024-02-29 20:09:43 +00:00
|
|
|
# Allow the consumer to access the private /tmp directory of the server.
|
|
|
|
# This is required to support consuming files via a local folder.
|
|
|
|
unitConfig.JoinsNamespaceOf = "paperless-task-queue.service";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
systemd.services.paperless-web = {
|
2021-08-18 13:19:15 +00:00
|
|
|
description = "Paperless web server";
|
2023-01-11 07:51:40 +00:00
|
|
|
# Bind to `paperless-scheduler` so that the web server never runs
|
|
|
|
# during migrations
|
|
|
|
bindsTo = [ "paperless-scheduler.service" ];
|
|
|
|
after = [ "paperless-scheduler.service" ];
|
2023-11-16 04:20:00 +00:00
|
|
|
# Setup PAPERLESS_SECRET_KEY.
|
|
|
|
# If this environment variable is left unset, paperless-ngx defaults
|
|
|
|
# to a well-known value, which is insecure.
|
|
|
|
script = let
|
|
|
|
secretKeyFile = "${cfg.dataDir}/nixos-paperless-secret-key";
|
|
|
|
in ''
|
|
|
|
if [[ ! -f '${secretKeyFile}' ]]; then
|
|
|
|
(
|
|
|
|
umask 0377
|
|
|
|
tr -dc A-Za-z0-9 < /dev/urandom | head -c64 | ${pkgs.moreutils}/bin/sponge '${secretKeyFile}'
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
export PAPERLESS_SECRET_KEY=$(cat '${secretKeyFile}')
|
|
|
|
if [[ ! $PAPERLESS_SECRET_KEY ]]; then
|
|
|
|
echo "PAPERLESS_SECRET_KEY is empty, refusing to start."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
exec ${pkg.python.pkgs.gunicorn}/bin/gunicorn \
|
|
|
|
-c ${pkg}/lib/paperless-ngx/gunicorn.conf.py paperless.asgi:application
|
|
|
|
'';
|
2021-08-18 13:19:15 +00:00
|
|
|
serviceConfig = defaultServiceConfig // {
|
|
|
|
User = cfg.user;
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
# gunicorn needs setuid, liblapack needs mbind
|
|
|
|
SystemCallFilter = defaultServiceConfig.SystemCallFilter ++ [ "@setuid mbind" ];
|
2022-02-20 05:27:41 +00:00
|
|
|
# Needs to serve web page
|
|
|
|
PrivateNetwork = false;
|
2022-09-09 14:08:57 +00:00
|
|
|
} // lib.optionalAttrs (cfg.port < 1024) {
|
|
|
|
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
|
|
|
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
environment = env // {
|
2022-09-09 14:08:57 +00:00
|
|
|
PYTHONPATH = "${pkg.python.pkgs.makePythonPath pkg.propagatedBuildInputs}:${pkg}/lib/paperless-ngx/src";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
# Allow the web interface to access the private /tmp directory of the server.
|
|
|
|
# This is required to support uploading files via the web interface.
|
2022-12-28 21:21:41 +00:00
|
|
|
unitConfig.JoinsNamespaceOf = "paperless-task-queue.service";
|
2021-08-18 13:19:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
users = optionalAttrs (cfg.user == defaultUser) {
|
|
|
|
users.${defaultUser} = {
|
|
|
|
group = defaultUser;
|
|
|
|
uid = config.ids.uids.paperless;
|
|
|
|
home = cfg.dataDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
groups.${defaultUser} = {
|
|
|
|
gid = config.ids.gids.paperless;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|