Merge pull request #242275 from Atemu/nixos/paperless-manage-toShellVars

nixos/paperless: use toShellVars for paperless-manage
This commit is contained in:
Martin Weinelt 2023-07-25 12:26:32 +02:00 committed by GitHub
commit 6847465f6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,14 +26,11 @@ let
lib.mapAttrs (_: toString) cfg.extraConfig lib.mapAttrs (_: toString) cfg.extraConfig
); );
manage = manage = pkgs.writeShellScript "manage" ''
let set -o allexport # Export the following env vars
setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env); ${lib.toShellVars env}
in exec ${pkg}/bin/paperless-ngx "$@"
pkgs.writeShellScript "manage" '' '';
${setupEnv}
exec ${pkg}/bin/paperless-ngx "$@"
'';
# Secure the services # Secure the services
defaultServiceConfig = { defaultServiceConfig = {
@ -172,6 +169,7 @@ in
description = lib.mdDoc "Web interface port."; description = lib.mdDoc "Web interface port.";
}; };
# FIXME this should become an RFC42-style settings attr
extraConfig = mkOption { extraConfig = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = { };
@ -180,11 +178,23 @@ in
See [the documentation](https://paperless-ngx.readthedocs.io/en/latest/configuration.html) See [the documentation](https://paperless-ngx.readthedocs.io/en/latest/configuration.html)
for available options. for available options.
Note that some options such as `PAPERLESS_CONSUMER_IGNORE_PATTERN` expect JSON values. Use `builtins.toJSON` to ensure proper quoting.
'';
example = literalExpression ''
{
PAPERLESS_OCR_LANGUAGE = "deu+eng";
PAPERLESS_DBHOST = "/run/postgresql";
PAPERLESS_CONSUMER_IGNORE_PATTERN = builtins.toJSON [ ".DS_STORE/*" "desktop.ini" ];
PAPERLESS_OCR_USER_ARGS = builtins.toJSON {
optimize = 1;
pdfa_image_compression = "lossless";
};
};
''; '';
example = {
PAPERLESS_OCR_LANGUAGE = "deu+eng";
PAPERLESS_DBHOST = "/run/postgresql";
};
}; };
user = mkOption { user = mkOption {