Something went wrong. Try again.
My Nix Configuration
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223{ data, lib, ... }:let
pns = data.services; marvinIP = data.hosts.marvin.ts.ip4; marvin = "http://${marvinIP}"; inherit (data) tsNet;
inrec {
/** Caddy multiple host creation function
Allows creation of a set of caddy hosts, based on a function and a list of service names
# Example ```nix mkHosts mkDirect [ "service-a" "service-b" ] ```
# Type ``` mkHosts :: Function -> [String] -> AttrSet ```
# Arguments
- [function] The function to be applied to the services list - [services] The services to pass to the function */ mkHosts = function: services: lib.listToAttrs (map function services);
/** Anubis-proxied host creation function
Allows creation of an Anubis-proxied host
# Example ```nix mkAnubis "service-a" => { service-a = { extraConfig = '' reverse_proxy 100.123.15.72:1234 { header_up X-Real-Ip {remote_host} header_up X-Http-Version {http.request.proto} } ''; }; } ```
# Type ``` mkAnubis :: String -> AttrSet ```
# Arguments
- [service] The service to create a caddy host for */ mkAnubis = service: lib.nameValuePair "${pns.${service}.extUrl}" { extraConfig = '' reverse_proxy ${marvin}:${toString pns.${service}.anubis} { header_up X-Real-Ip {remote_host} header_up X-Http-Version {http.request.proto} } ''; };
/** Anubis-proxied multiple host creation function
Allows creation of several Anubis-proxied hosts
# Example ```nix mkAnubisSites ["service-a"] => { service-a = { extraConfig = '' reverse_proxy 100.123.15.72:1234 { header_up X-Real-Ip {remote_host} header_up X-Http-Version {http.request.proto} } ''; }; } ```
# Type ``` mkAnubisSites :: [String] -> AttrSet ```
# Arguments
- [services] The list of services to create Caddy hosts for */ mkAnubisSites = services: mkHosts mkAnubis services;
/** Tailscale-only host creation function
Allows creation of a service that will only be offered inside the tailnet.
# Example ```nix mkTs "service-a" => { "service-a.example.ts.net" = { extraConfig = '' bind tailscale/service-a tailscale_auth reverse_proxy 100.123.15.72:1234 ''; }; } ```
# Type ``` mkTs :: String -> AttrSet ```
# Arguments
- [service] The service to create a Tailscale-only host for */ mkTs = service: lib.nameValuePair "${pns.${service}.tsHost}.${tsNet}" { extraConfig = '' bind tailscale/${pns.${service}.tsHost} tailscale_auth reverse_proxy ${marvin}:${toString pns.${service}.port} ''; };
/** Tailscale-only multiple host creation function
Allows creation of several Tailscale-only hosts
# Example ```nix mkTs ["service-a"] => { "service-a.example.ts.net" = { extraConfig = '' bind tailscale/service-a tailscale_auth reverse_proxy 100.123.15.72:1234 ''; }; } ```
# Type ``` mkTsSites :: [String] -> AttrSet ```
# Arguments
- [services] The list of services to create Tailscale-only hosts for */ mkTsSites = services: mkHosts mkTs services;
/** Direct connection host creation function
Allows creation of a service that will be proxied via Caddy, but not protected by Anubis.
# Example ```nix mkDirect "service-a" => { "service-a.example.com" = { extraConfig = '' reverse_proxy 100.123.15.72:1234 ''; }; } ```
# Type ``` mkDirect :: String -> AttrSet ```
# Arguments
- [service] The service to create a direct host for */ mkDirect = service: lib.nameValuePair "${pns.${service}.extUrl}" { extraConfig = '' reverse_proxy ${marvin}:${toString pns.${service}.port} ''; };
/** Direct connection multiple host creation function
Allows creation of several directly-connected hosts
# Example ```nix mkDirectSites ["service-a"] => { "service-a.example.com" = { extraConfig = '' reverse_proxy 100.123.15.72:1234 ''; }; } ```
# Type ``` mkDirectSites :: [String] -> AttrSet ```
# Arguments
- [services] The list of services to create Tailscale-only hosts for */ mkDirectSites = services: mkHosts mkDirect services;}