From 01be52c037e8a457ac51bd37b755295baa7c83c6 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 9 Jul 2024 05:25:23 -0400 Subject: lib: use rfc0145 doc-strings --- lib/nginx.nix | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'lib/nginx.nix') 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}"); } -- cgit v1.2.3