From e7358b192a3cdfc7d64fa2a21321df03b2256345 Mon Sep 17 00:00:00 2001 From: Evan Danaher Date: Thu, 9 Mar 2017 13:02:49 -0500 Subject: nginx: Assert that either root or alias is null. If both are set, nginx won't start. More error checking is certainly in order, but this seems like a reasonable start. --- nixos/modules/services/web-servers/nginx/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nixos/modules/services/web-servers/nginx') diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 4ad272deb376..72cc10caef11 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -380,6 +380,15 @@ in config = mkIf cfg.enable { # TODO: test user supplied config file pases syntax test + assertions = let hostOrAliasIsNull = l: l.root == null || l.alias == null; in [ { + assertion = all hostOrAliasIsNull (attrValues virtualHosts); + message = "Only one of nginx root or alias can be specified on a virtualHost."; + } { + assertion = all (host: all hostOrAliasIsNull (attrValues host.locations)) (attrValues virtualHosts); + message = "Only one of nginx root or alias can be specified on a location."; + } + ]; + systemd.services.nginx = { description = "Nginx Web Server"; after = [ "network.target" ]; -- cgit 1.4.1