@@ -7,7 +7,7 @@
77import ./make-test-python.nix ({ pkgs, ... }: {
88 name = "nginx";
99 meta = with pkgs.stdenv.lib.maintainers; {
10− maintainers = [ mbbx6spp ];
10+ maintainers = [ mbbx6spp danbst ];
1111 };
1212
1313 nodes = {
@@ -59,6 +59,11 @@ import ./make-test-python.nix ({ pkgs, ... }: {
5959 {
6060 services.nginx.package = pkgs.nginxUnstable;
6161 }
62+
63+ {
64+ services.nginx.package = pkgs.nginxUnstable;
65+ services.nginx.virtualHosts."!@$$(#*%".locations."~@#*$*!)".proxyPass = ";;;";
66+ }
6267 ];
6368 };
6469
@@ -68,6 +73,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
6873 etagSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-1";
6974 justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-2";
7075 reloadRestartSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-3";
76+ reloadWithErrorsSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-4";
7177 in ''
7278 url = "http://localhost/index.html"
7379
@@ -110,5 +116,17 @@ import ./make-test-python.nix ({ pkgs, ... }: {
110116 )
111117 webserver.wait_for_unit("nginx")
112118 webserver.succeed("journalctl -u nginx | grep -q -i stopped")
119+
120+ with subtest("nixos-rebuild --switch should fail when there are configuration errors"):
121+ webserver.fail(
122+ "${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
123+ )
124+ webserver.succeed("[[ $(systemctl is-failed nginx-config-reload) == failed ]]")
125+ webserver.succeed("[[ $(systemctl is-failed nginx) == active ]]")
126+ # just to make sure operation is idempotent. During development I had a situation
127+ # when first time it shows error, but stops showing it on subsequent rebuilds
128+ webserver.fail(
129+ "${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
130+ )
113131 '';
114132})