{ povSelf, hostConfig, config, lib, dnsNix, ... }: let inherit (lib) types; cfg = lib.getAttrFromPath povSelf config; in { options = { enable = { type = types.bool; default = false; }; domain = { type = types.str; default = "zaphyra.eu"; }; }; config = lib.mkIf cfg.enable { dns.zones."${cfg.domain}".subdomains = { "ip" = (dnsNix.combinators.host hostConfig.networking.ip4Address hostConfig.networking.ip6Address); "ip4".A = [ hostConfig.networking.ip4Address ]; "ip6".AAAA = [ hostConfig.networking.ip6Address ]; }; services.nginx.virtualHosts."ip.${cfg.domain}" = { useACMEHost = "${config.networking.fqdn}"; forceSSL = true; kTLS = true; locations."/" = { extraConfig = "types { } default_type 'text/html; charset=utf-8';"; return = '' 200 '
Use bash and curl: curl ip{4,6}.${cfg.domain}
Because any other "Whats my IP?"-tool sucks. Host yourself :3
' ''; }; }; services.nginx.virtualHosts."ip4.${cfg.domain}" = { useACMEHost = "${config.networking.fqdn}"; forceSSL = true; kTLS = true; locations."/" = { return = "200 '$remote_addr\n'"; extraConfig = '' types { } default_type "text/plain; charset=utf-8"; add_header Access-Control-Allow-Origin *; ''; }; }; services.nginx.virtualHosts."ip6.${cfg.domain}" = { useACMEHost = "${config.networking.fqdn}"; forceSSL = true; kTLS = true; locations."/" = { return = "200 '$remote_addr\n'"; extraConfig = '' types { } default_type "text/plain; charset=utf-8"; add_header Access-Control-Allow-Origin *; ''; }; }; }; }