feat(wordpress/module): Factorize ip construction

This commit is contained in:
Tom Hubrecht 2024-01-08 17:59:22 +01:00
parent bdc23df66c
commit 9c457666f5

View file

@ -9,6 +9,7 @@ let
cfg = config.services.wp-containers;
mkName = builtins.replaceStrings [ "." ] [ "-" ];
mkIp = ip: i: "${ip}.${builtins.toString i}";
mkConfig = { name, value, i }: {
services.wordpress = {
@ -25,7 +26,7 @@ let
networking = {
hostName = mkName name;
hosts."10.0.0.${builtins.toString i}" = [ name ];
hosts.${mkIp "10.0.0" i} = [ name ];
firewall.allowedTCPPorts = [ 443 ];
};
@ -51,8 +52,8 @@ let
mountPoint = certs.${site.name}.directory;
};
hostAddress = "10.31.41.${builtins.toString i}";
localAddress = "10.0.0.${builtins.toString i}";
hostAddress = mkIp "10.31.41" i;
localAddress = mkIp "10.0.0" i;
autoStart = true;
@ -66,9 +67,8 @@ let
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "https://10.31.41.${builtins.toString i}:${
builtins.toString (cfg.basePort + i)
}";
locations."/".proxyPass =
"https://${mkIp "10.31.41" i}:${builtins.toString (cfg.basePort + i)}";
};
};