utils: add utility functions

Changed files
+44
docs
global
+19
docs/utils.md
···
+
# utility functions
+
+
## `utils.mkVhost`
+
make virtual host with sensible defaults
+
+
pass in a set to override the defaults.
+
+
## `utils.mkSimpleProxy`
+
make a simple reverse proxy
+
+
takes a set:
+
```nix
+
{
+
port,
+
protocol ? "http",
+
location ? "/",
+
websockets ? false
+
}
+
```
+25
global/utils.nix
···
+
# see /docs/utils.md for a usage guide
+
+
{ pkgs, ... }:
+
+
let
+
lib = pkgs.lib;
+
in {
+
mkVhost = opts: {
+
# ideally mkOverride/mkDefault would be used, but i have 0 idea how it works.
+
forceSSL = true;
+
useACMEHost = "global.c.soopy.moe";
+
} // opts;
+
+
mkSimpleProxy = {
+
port,
+
protocol ? "http",
+
location ? "/",
+
websockets ? false
+
}: mkVhost {
+
locations."${location}" = {
+
proxyPass = "${protocol}://localhost:${toString port}";
+
proxyWebsockets = websockets;
+
};
+
};
+
}