summaryrefslogtreecommitdiff
path: root/lib/nginx.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nginx.nix')
-rw-r--r--lib/nginx.nix55
1 files changed, 49 insertions, 6 deletions
diff --git a/lib/nginx.nix b/lib/nginx.nix
index e7c22c3..c2c99fb 100644
--- a/lib/nginx.nix
+++ b/lib/nginx.nix
@@ -1,7 +1,28 @@
lib: {
- # string -> int -> { }
- # create an nginx virtualHost submodule proxying local port
- # `port` to `endpoint`
+ /**
+ Create an NGINX virtualHost submodule proxying a local port
+
+ # Example
+
+ ```nix
+ mkProxy "/" "3000"
+ => {
+ proxyPass = "http://localhost:3000";
+ proxyWebsockets = true;
+ }
+ ```
+
+ # Type
+
+ ```
+ mkProxy :: String -> Number -> AttrSet
+ ```
+
+ # Arguments
+
+ - [endpoint] virtualHost endpoint that `port` will be proxied towards
+ - [port] Port to be proxied
+ */
mkProxy = endpoint: port: {
"${endpoint}" = {
proxyPass = "http://localhost:${toString port}";
@@ -9,8 +30,30 @@ lib: {
};
};
- # string -> { } -> { }
- # transform the names of an attribute set of nginx virtualHosts
- # into a full subdomain
+ /**
+ Transform the names of an attribute set of nginx virtualHosts into a full subdomain
+
+ # Example
+
+ ```nix
+ toVHosts "example.com" {
+ subdomain = { };
+ }
+ => {
+ "subdomain.example.com" = { };
+ }
+ ```
+
+ # Type
+
+ ```
+ toVHosts :: String -> AttrSet -> AttrSet
+ ```
+
+ # Arguments
+
+ - [domain] Root domain used
+ - [subdomainMap] A name value pair of subdomains and their virtualHost options
+ */
toVHosts = domain: lib.mapAttrs' (name: lib.nameValuePair "${name}.${domain}");
}