diff --git a/services/nginx.nix b/services/nginx.nix index 3b75983..a5e0129 100644 --- a/services/nginx.nix +++ b/services/nginx.nix @@ -2,23 +2,23 @@ let network = import ../data/network.nix; virtualHostFn = name: service: let - domain = if service.domainOverride == null - then "${name}.${network.local_domain}" - else service.domainOverride; - locationList = if service.reverse_proxy.endpoints == null - then ["/"] - else service.reverse_proxy.endpoints; + domain = if service ? domainOverride + then service.domainOverride + else "${name}.${network.local_domain}"; + locationList = if service.reverse_proxy ? endpoints + then service.reverse_proxy.endpoints + else ["/"]; locationsData = builtins.listToAttrs (map (endpointName: { name = endpointName; value = { proxyPass = "http://127.0.0.1:${builtins.toString service.reverse_proxy.port}/"; proxyWebsockets = true; }; - })); - serverAlias = lib.optionalAttrs (service.reverse_proxy.aliases != null) { + }) locationList); + serverAlias = lib.optionalAttrs (service.reverse_proxy ? aliases) { serverAliases = map (alias: "${alias}.${domain}") service.reverse_proxy.aliases; }; - myExtraConfig = if service.reverse_proxy.extraConfig != null + myExtraConfig = if service.reverse_proxy ? extraConfig then service.reverse_proxy.extraConfig else {}; in