nix-config/hosts/nixedo/modules/paperless.nix

64 lines
1.2 KiB
Nix
Raw Normal View History

2025-04-30 01:10:02 +01:00
{ config, lib, ... }:
2025-04-30 01:10:02 +01:00
with lib;
let
cfg = homelab.services.paperless;
homelab = config.features.homelab;
2025-04-30 01:10:02 +01:00
service = "paperless";
in
{
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;
};
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} = {
enable = true;
2025-04-30 01:10:02 +01:00
dataDir = "/mnt/media/${service}";
2025-01-20 17:52:44 +00:00
settings = {
2025-04-30 01:10:02 +01:00
PAPERLESS_URL = "https://${cfg.url}";
};
};
2025-04-30 01:10:02 +01:00
nginx.virtualHosts."${cfg.url}" = {
forceSSL = true;
2025-04-30 01:10:02 +01:00
useACMEHost = homelab.baseDomain;
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-30 01:10:02 +01:00
};
}