easier to read nginx file

This commit is contained in:
Danilo Reyes 2025-09-28 02:15:41 -06:00
parent cd9e738c3c
commit f400b8922a

View File

@ -1,77 +1,41 @@
{ lib, config, ... }:
let
setup = import ../servers/setup.nix { inherit lib config; };
standardProxyServices = {
"firefox-syncserver" = {
type = "proxyReverse";
};
"readeck" = {
type = "proxyReverse";
};
"microbin" = {
type = "proxyReverse";
};
"ryot" = {
type = "proxyReverse";
};
"bazarr" = {
type = "proxyReverse";
};
"shiori" = {
type = "proxyReverse";
};
"metube" = {
type = "proxyReverse";
};
"maloja" = {
type = "proxyReverse";
};
"vaultwarden" = {
type = "proxyReverse";
};
"mealie" = {
type = "proxyReverse";
};
"kavita" = {
type = "proxyReverse";
};
"multi-scrobbler" = {
type = "proxyReverse";
};
"nix-serve" = {
type = "proxyReverse";
};
"audiobookshelf" = {
type = "proxyReverseFix";
};
"lidarr" = {
type = "proxyReverseFix";
};
"gitea" = {
type = "proxyReverseFix";
};
"prowlarr" = {
type = "proxyReverseFix";
};
"ombi" = {
type = "proxyReverseFix";
};
"radarr" = {
type = "proxyReverseFix";
};
"sonarr" = {
type = "proxyReverseFix";
};
"stash" = {
type = "proxyReverseFix";
};
"atticd" = {
type = "proxyReverseFix";
};
"homepage" = {
type = "proxyReversePrivate";
};
};
proxyReverseServices = [
"firefox-syncserver"
"readeck"
"microbin"
"ryot"
"bazarr"
"shiori"
"metube"
"maloja"
"vaultwarden"
"mealie"
"kavita"
"multi-scrobbler"
"nix-serve"
];
proxyReverseFixServices = [
"audiobookshelf"
"lidarr"
"gitea"
"prowlarr"
"ombi"
"radarr"
"sonarr"
"stash"
"atticd"
];
proxyReversePrivateServices = [
"homepage"
];
mkServiceConfig =
type: services: lib.listToAttrs (map (name: lib.nameValuePair name { inherit type; }) services);
standardProxyServices =
(mkServiceConfig "proxyReverse" proxyReverseServices)
// (mkServiceConfig "proxyReverseFix" proxyReverseFixServices)
// (mkServiceConfig "proxyReversePrivate" proxyReversePrivateServices);
generateProxyConfig =
serviceName: serviceConfig:
let
@ -87,10 +51,9 @@ let
throw "Unknown proxy type: ${serviceConfig.type}";
in
lib.nameValuePair cfg.host (lib.mkIf cfg.enableProxy (proxyFunc cfg));
standardProxyConfigs = lib.mapAttrs' generateProxyConfig standardProxyServices;
in
{
config = lib.mkIf config.my.enableProxy {
services.nginx.virtualHosts = standardProxyConfigs;
services.nginx.virtualHosts = lib.mapAttrs' generateProxyConfig standardProxyServices;
};
}