Refactor homelab modules

This commit is contained in:
Oliver Davies 2025-04-30 01:10:02 +01:00
parent e6f269b123
commit fe508bd127
9 changed files with 224 additions and 83 deletions

View file

@ -1,30 +1,43 @@
{ config, ... }:
{ config, lib, ... }:
with lib;
let
cfg = homelab.services.paperless;
homelab = config.nixosModules.homelab;
service = "paperless";
in
{
services =
let
cfg = config.services.paperless;
hostname = "paperless.oliverdavies.uk";
in
{
paperless = {
options.nixosModules.homelab.services.${service} = {
enable = mkEnableOption "Enable ${service}";
url = mkOption {
default = "${service}.${homelab.baseDomain}";
type = types.str;
};
};
config = mkIf cfg.enable {
services = {
${service} = {
enable = true;
dataDir = "/mnt/media/paperless";
dataDir = "/mnt/media/${service}";
settings = {
PAPERLESS_URL = "https://${hostname}";
PAPERLESS_URL = "https://${cfg.url}";
};
};
nginx.virtualHosts."${hostname}" = {
nginx.virtualHosts."${cfg.url}" = {
forceSSL = true;
useACMEHost = "oliverdavies.uk";
useACMEHost = homelab.baseDomain;
locations."/" = {
proxyPass = "http://localhost:${toString cfg.port}";
proxyPass = "http://localhost:${toString config.services.${service}.port}";
recommendedProxySettings = true;
};
};
};
};
}