fix(nginx): proxied listen

This commit is contained in:
arcnmx 2024-04-29 12:01:35 -07:00
parent f2c7178486
commit f9b02a03a4
18 changed files with 185 additions and 90 deletions

View file

@ -11,12 +11,22 @@ in {
assertion = config.ports.http.port == cfg.defaultHTTPListenPort && config.ports.https.port == cfg.defaultSSLListenPort;
message = "ports mismatch";
};
assertProxied = nixosConfig: cfg: {
assertion = config.ports.proxied.enable == cfg.proxied.enabled;
message = "proxied mismatch";
};
assertProxiedPort = nixosConfig: cfg: {
assertion = !config.ports.proxied.enable || config.ports.proxied.port == cfg.proxied.listenPort;
message = "proxied.port mismatch";
};
in {
nixos = {
serviceAttr = "nginx";
assertions = mkIf config.enable [
(mkAssertion assertPorts)
];
assertions = mkIf config.enable (map mkAssertion [
assertPorts
assertProxied
assertProxiedPort
]);
};
defaults.port.listen = mkAlmostOptionDefault "lan";
ports = mapAttrs (_: mapAlmostOptionDefaults) {
@ -29,6 +39,12 @@ in {
port = 443;
protocol = "https";
};
proxied = {
enable = false;
port = 9080;
protocol = "http";
listen = "lan";
};
};
};
}