2025-04-30 01:10:02 +01:00
|
|
|
{ config, lib, ... }:
|
2024-12-13 22:18:30 +00:00
|
|
|
|
2025-04-30 01:10:02 +01:00
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = homelab.services.paperless;
|
2025-04-30 03:09:17 +01:00
|
|
|
homelab = config.features.homelab;
|
2025-04-30 01:10:02 +01:00
|
|
|
service = "paperless";
|
|
|
|
in
|
2024-12-13 22:18:30 +00:00
|
|
|
{
|
2025-04-30 03:09:17 +01:00
|
|
|
options.features.homelab.services.${service} = {
|
2025-04-30 01:10:02 +01:00
|
|
|
enable = mkEnableOption "Enable ${service}";
|
|
|
|
|
|
|
|
url = mkOption {
|
|
|
|
default = "${service}.${homelab.baseDomain}";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2025-04-30 11:58:59 +01:00
|
|
|
|
|
|
|
homepage.name = mkOption {
|
|
|
|
default = "Paperless-ngx";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
homepage.description = mkOption {
|
|
|
|
default = "Document management system";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
homepage.icon = mkOption {
|
|
|
|
default = "paperless";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
homepage.category = mkOption {
|
|
|
|
default = "Services";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2025-04-30 01:10:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services = {
|
|
|
|
${service} = {
|
2025-04-28 00:23:46 +01:00
|
|
|
enable = true;
|
2025-01-01 14:45:03 +00:00
|
|
|
|
2025-04-30 01:10:02 +01:00
|
|
|
dataDir = "/mnt/media/${service}";
|
2025-01-20 17:52:44 +00:00
|
|
|
|
2025-04-28 00:23:46 +01:00
|
|
|
settings = {
|
2025-04-30 01:10:02 +01:00
|
|
|
PAPERLESS_URL = "https://${cfg.url}";
|
2025-04-28 00:23:46 +01:00
|
|
|
};
|
2025-01-01 14:45:03 +00:00
|
|
|
};
|
|
|
|
|
2025-04-30 01:10:02 +01:00
|
|
|
nginx.virtualHosts."${cfg.url}" = {
|
2025-04-28 00:23:46 +01:00
|
|
|
forceSSL = true;
|
2025-04-30 01:10:02 +01:00
|
|
|
useACMEHost = homelab.baseDomain;
|
2025-04-28 00:23:46 +01:00
|
|
|
|
|
|
|
locations."/" = {
|
2025-04-30 01:10:02 +01:00
|
|
|
proxyPass = "http://localhost:${toString config.services.${service}.port}";
|
2025-04-28 02:07:10 +01:00
|
|
|
recommendedProxySettings = true;
|
2025-04-28 00:23:46 +01:00
|
|
|
};
|
|
|
|
};
|
2024-12-13 22:18:30 +00:00
|
|
|
};
|
2025-04-30 01:10:02 +01:00
|
|
|
};
|
2024-12-13 22:18:30 +00:00
|
|
|
}
|