summaryrefslogtreecommitdiff
path: root/lib/nginx.nix
blob: 0564dbadc136cbb8a1dcb6ed45cdb1ca6b8290a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
lib: {
  # string -> int -> { }
  # create an nginx virtualHost submodule proxying local port
  # `port` to `endpoint`
  mkProxy = endpoint: port: {
    "${endpoint}" = {
      proxyPass = "http://localhost:${toString port}";
      proxyWebsockets = true;
    };
  };

  # string -> { } -> { }
  # transform the names of an attribute set of nginx virtualHosts
  # into a full subdomain
  toVHosts = domain:
    lib.mapAttrs' (
      name: lib.nameValuePair "${name}.${domain}"
    );
}