flakes/modules/nixos/services/paperless/default.nix

68 lines
1.6 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}:
{
options.snowflake.services.paperless = {
enable = lib.mkEnableOption "Enable paperless service";
domain = lib.mkOption {
type = lib.types.str;
default = "";
description = "Configuration domain to use for the paperless service";
};
passwordFile = lib.mkOption {
description = "Age module containing the password to use for paperless";
};
adminUser = lib.mkOption {
type = lib.types.str;
description = "Administrator username for the paperless service";
};
};
config =
let
cfg = config.snowflake.services.paperless;
in
lib.mkIf cfg.enable {
age.secrets.paperless = {
inherit (cfg.passwordFile) file;
owner = "paperless";
group = "paperless";
};
services.paperless = {
enable = true;
package = pkgs.paperless-ngx;
passwordFile = config.age.secrets.paperless.path;
settings = {
PAPERLESS_URL = "https://${cfg.domain}";
PAPERLESS_OCR_LANGUAGE = "eng";
PAPEERLESS_TASK_WORKERS = 4;
PAPERLESS_THREADS_PER_WORKER = 4;
PAPERLESS_ADMIN_USER = cfg.adminUser;
};
};
# Requires services.nginx.enable.
services.nginx = {
virtualHosts = {
"${cfg.domain}" = {
serverName = "${cfg.domain}";
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.paperless.port}/";
};
};
};
};
};
}