summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/nginx
diff options
context:
space:
mode:
authorEvan Danaher <edanaher@edanaher.net>2017-03-09 13:02:49 -0500
committerEvan Danaher <edanaher@edanaher.net>2017-03-09 13:02:49 -0500
commite7358b192a3cdfc7d64fa2a21321df03b2256345 (patch)
tree343d2969e23981655ae90a114a0ccbacce66760b /nixos/modules/services/web-servers/nginx
parentff2e2e82ccc2eebc36220613b332efa475dcca51 (diff)
downloadnixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.tar
nixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.tar.gz
nixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.tar.bz2
nixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.tar.lz
nixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.tar.xz
nixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.tar.zst
nixlib-e7358b192a3cdfc7d64fa2a21321df03b2256345.zip
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.
Diffstat (limited to 'nixos/modules/services/web-servers/nginx')
-rw-r--r--nixos/modules/services/web-servers/nginx/default.nix9
1 files changed, 9 insertions, 0 deletions
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" ];