Skip to content

Commit

Permalink
Merge pull request #242275 from Atemu/nixos/paperless-manage-toShellVars
Browse files Browse the repository at this point in the history
nixos/paperless: use toShellVars for paperless-manage
  • Loading branch information
mweinelt authored Jul 25, 2023
2 parents 821c727 + 2616bb7 commit 6847465
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions nixos/modules/services/misc/paperless.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ let
lib.mapAttrs (_: toString) cfg.extraConfig
);

manage =
let
setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env);
in
pkgs.writeShellScript "manage" ''
${setupEnv}
exec ${pkg}/bin/paperless-ngx "$@"
'';
manage = pkgs.writeShellScript "manage" ''
set -o allexport # Export the following env vars
${lib.toShellVars env}
exec ${pkg}/bin/paperless-ngx "$@"
'';

# Secure the services
defaultServiceConfig = {
Expand Down Expand Up @@ -172,6 +169,7 @@ in
description = lib.mdDoc "Web interface port.";
};

# FIXME this should become an RFC42-style settings attr
extraConfig = mkOption {
type = types.attrs;
default = { };
Expand All @@ -180,11 +178,23 @@ in
See [the documentation](https://paperless-ngx.readthedocs.io/en/latest/configuration.html)
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 {
Expand Down

0 comments on commit 6847465

Please sign in to comment.