1# see /docs/utils.md for a usage guide
2{
3 inputs,
4 system,
5 ...
6}: let
7 lib = inputs.nixpkgs.lib;
8in rec {
9 mkVhost = opts:
10 lib.mkMerge [
11 {
12 forceSSL = lib.mkDefault true;
13 useACMEHost = lib.mkDefault "global.c.soopy.moe";
14 kTLS = lib.mkDefault true;
15
16 locations."/_cgi/error/" = {
17 alias = "${inputs.mystia.packages.${system}.staticly}/nginx_error_pages/";
18 };
19 extraConfig = ''
20 error_page 503 /_cgi/error/503.html;
21 error_page 502 /_cgi/error/502.html;
22 error_page 404 /_cgi/error/404.html;
23 '';
24 }
25 opts
26 ];
27
28 mkSimpleProxy = {
29 port,
30 protocol ? "http",
31 location ? "/",
32 websockets ? false,
33 extraConfig ? {},
34 }:
35 mkVhost (lib.mkMerge [
36 extraConfig
37 {
38 locations."${location}" = {
39 proxyPass = "${protocol}://localhost:${toString port}";
40 proxyWebsockets = websockets;
41 };
42 }
43 ]);
44
45 genSecrets = namespace: files: value:
46 lib.genAttrs (
47 map (x: namespace + lib.optionalString (lib.stringLength namespace != 0) "/" + x) files
48 ) (_: value);
49}