My Nix Configuration
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

[lib] caddy: add doc comments

dish fa8d4b39 12cac7e6

+175
+175
lib/caddy.nix
··· 8 8 9 9 in 10 10 rec { 11 + 12 + /** 13 + Caddy multiple host creation function 14 + 15 + Allows creation of a set of caddy hosts, based on a function and a list of service names 16 + 17 + # Example 18 + ```nix 19 + mkHosts mkDirect [ "service-a" "service-b" ] 20 + ``` 21 + 22 + # Type 23 + ``` 24 + mkHosts :: Function -> [String] -> AttrSet 25 + ``` 26 + 27 + # Arguments 28 + 29 + - [function] The function to be applied to the services list 30 + - [services] The services to pass to the function 31 + */ 11 32 mkHosts = function: services: lib.listToAttrs (map function services); 12 33 34 + /** 35 + Anubis-proxied host creation function 36 + 37 + Allows creation of an Anubis-proxied host 38 + 39 + # Example 40 + ```nix 41 + mkAnubis "service-a" 42 + => { service-a = { 43 + extraConfig = '' 44 + reverse_proxy 100.123.15.72:1234 { 45 + header_up X-Real-Ip {remote_host} 46 + header_up X-Http-Version {http.request.proto} 47 + } 48 + ''; 49 + }; } 50 + ``` 51 + 52 + # Type 53 + ``` 54 + mkAnubis :: String -> AttrSet 55 + ``` 56 + 57 + # Arguments 58 + 59 + - [service] The service to create a caddy host for 60 + */ 13 61 mkAnubis = 14 62 service: 15 63 lib.nameValuePair "${pns.${service}.extUrl}" { ··· 21 69 ''; 22 70 }; 23 71 72 + /** 73 + Anubis-proxied multiple host creation function 74 + 75 + Allows creation of several Anubis-proxied hosts 76 + 77 + # Example 78 + ```nix 79 + mkAnubisSites ["service-a"] 80 + => { service-a = { 81 + extraConfig = '' 82 + reverse_proxy 100.123.15.72:1234 { 83 + header_up X-Real-Ip {remote_host} 84 + header_up X-Http-Version {http.request.proto} 85 + } 86 + ''; 87 + }; } 88 + ``` 89 + 90 + # Type 91 + ``` 92 + mkAnubisSites :: [String] -> AttrSet 93 + ``` 94 + 95 + # Arguments 96 + 97 + - [services] The list of services to create Caddy hosts for 98 + */ 24 99 mkAnubisSites = services: mkHosts mkAnubis services; 25 100 101 + /** 102 + Tailscale-only host creation function 103 + 104 + Allows creation of a service that will only be offered inside the tailnet. 105 + 106 + # Example 107 + ```nix 108 + mkTs "service-a" 109 + => { "service-a.example.ts.net" = { 110 + extraConfig = '' 111 + bind tailscale/service-a 112 + tailscale_auth 113 + reverse_proxy 100.123.15.72:1234 114 + ''; 115 + }; } 116 + ``` 117 + 118 + # Type 119 + ``` 120 + mkTs :: String -> AttrSet 121 + ``` 122 + 123 + # Arguments 124 + 125 + - [service] The service to create a Tailscale-only host for 126 + */ 26 127 mkTs = 27 128 service: 28 129 lib.nameValuePair "${pns.${service}.tsHost}.${tsNet}" { ··· 33 134 ''; 34 135 }; 35 136 137 + /** 138 + Tailscale-only multiple host creation function 139 + 140 + Allows creation of several Tailscale-only hosts 141 + 142 + # Example 143 + ```nix 144 + mkTs ["service-a"] 145 + => { "service-a.example.ts.net" = { 146 + extraConfig = '' 147 + bind tailscale/service-a 148 + tailscale_auth 149 + reverse_proxy 100.123.15.72:1234 150 + ''; 151 + }; } 152 + ``` 153 + 154 + # Type 155 + ``` 156 + mkTsSites :: [String] -> AttrSet 157 + ``` 158 + 159 + # Arguments 160 + 161 + - [services] The list of services to create Tailscale-only hosts for 162 + */ 36 163 mkTsSites = services: mkHosts mkTs services; 37 164 165 + /** 166 + Direct connection host creation function 167 + 168 + Allows creation of a service that will be proxied via Caddy, but not protected by Anubis. 169 + 170 + # Example 171 + ```nix 172 + mkDirect "service-a" 173 + => { "service-a.example.com" = { 174 + extraConfig = '' 175 + reverse_proxy 100.123.15.72:1234 176 + ''; 177 + }; } 178 + ``` 179 + 180 + # Type 181 + ``` 182 + mkDirect :: String -> AttrSet 183 + ``` 184 + 185 + # Arguments 186 + 187 + - [service] The service to create a direct host for 188 + */ 38 189 mkDirect = 39 190 service: 40 191 lib.nameValuePair "${pns.${service}.extUrl}" { ··· 43 194 ''; 44 195 }; 45 196 197 + /** 198 + Direct connection multiple host creation function 199 + 200 + Allows creation of several directly-connected hosts 201 + 202 + # Example 203 + ```nix 204 + mkDirectSites ["service-a"] 205 + => { "service-a.example.com" = { 206 + extraConfig = '' 207 + reverse_proxy 100.123.15.72:1234 208 + ''; 209 + }; } 210 + ``` 211 + 212 + # Type 213 + ``` 214 + mkDirectSites :: [String] -> AttrSet 215 + ``` 216 + 217 + # Arguments 218 + 219 + - [services] The list of services to create Tailscale-only hosts for 220 + */ 46 221 mkDirectSites = services: mkHosts mkDirect services; 47 222 }