add Status helper for nginx, add .gitreview
Change-Id: I2d0de7c3d11a0dcc111585c556c96c06ffc16374
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..e453217
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=ssh.clicks.codes
+port=29418
+defaultbranch=main
+project=Clicks/NixHelpers.git
diff --git a/nginx.nix b/nginx.nix
index 41cc114..08dea07 100644
--- a/nginx.nix
+++ b/nginx.nix
@@ -67,12 +67,16 @@
inherit path service;
type = "path";
};
+ Status = statusCode: {
+ inherit statusCode;
+ type = "status";
+ };
Merge = let
# builtins.length and count up
_iterateCompose = services: currentConfig: currentPath: secure: priority: i:
if i < builtins.length services
- then _iterateCompose services (_merge (builtins.elemAt services i) currentConfig currentPath secure priority+i) currentPath secure priority (i+1)
+ then _iterateCompose services (_merge (builtins.elemAt services i) currentConfig currentPath secure (priority+i)) currentPath secure priority (i+1)
else currentConfig;
_iterateMerge = i: current: services:
@@ -101,7 +105,7 @@
else if service.type == "reverseproxy"
then (lib.recursiveUpdate currentConfig {
value.locations.${currentPath} = {
- proxyPass = service.to;
+ proxyPass = "http://${service.to}";
proxyWebsockets = true;
recommendedProxySettings = true;
};
@@ -151,6 +155,12 @@
then _merge service.service currentConfig service.path service.secure priority
else if service.type == "compose"
then (_iterateCompose service.services currentConfig currentPath secure priority 0)
+ else if service.type == "status"
+ then (lib.recursiveUpdate currentConfig {
+ value.locations.${currentPath} = {
+ return = "${builtins.toString service.statusCode}";
+ };
+ })
else throw "Unknown service type: ${service.type}";
in (services: lib.pipe services [
(_iterateMerge 0 [])