2024-02-11 22:24:35 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.custom.dns;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.custom.dns = {
|
|
|
|
enable = lib.mkEnableOption "dns";
|
|
|
|
|
2024-04-27 17:06:20 +01:00
|
|
|
authoritative = {
|
|
|
|
ipv4 = lib.mkOption {
|
|
|
|
description = "authoritative ipv4 mappings";
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
ipv6 = lib.mkOption {
|
|
|
|
description = "authoritative ipv6 mappings";
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-11 22:24:35 +00:00
|
|
|
tailscale =
|
|
|
|
{
|
|
|
|
ipv4 = lib.mkOption {
|
|
|
|
description = "tailscale ipv4 address";
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
ipv6 = lib.mkOption {
|
|
|
|
description = "tailscale ipv6 address";
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-04-27 17:06:20 +01:00
|
|
|
custom.dns.authoritative = {
|
|
|
|
ipv4 = {
|
|
|
|
uk = {
|
|
|
|
co = {
|
|
|
|
hillion = {
|
|
|
|
ts = {
|
|
|
|
cx = {
|
2024-04-28 10:26:06 +01:00
|
|
|
boron = "100.113.188.46";
|
2024-04-27 17:06:20 +01:00
|
|
|
};
|
|
|
|
home = {
|
|
|
|
microserver = "100.105.131.47";
|
|
|
|
router = "100.105.71.48";
|
|
|
|
};
|
|
|
|
jakehillion-terminals = { gendry = "100.70.100.77"; };
|
|
|
|
lt = { be = "100.105.166.79"; };
|
|
|
|
pop = { li = "100.106.87.35"; };
|
|
|
|
storage = {
|
|
|
|
theon = "100.104.142.22";
|
|
|
|
tywin = "100.115.31.91";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ipv6 = {
|
|
|
|
uk = {
|
|
|
|
co = {
|
|
|
|
hillion = {
|
|
|
|
ts = {
|
|
|
|
cx = {
|
2024-04-28 10:26:06 +01:00
|
|
|
boron = "fd7a:115c:a1e0::2a01:bc2f";
|
2024-04-27 17:06:20 +01:00
|
|
|
};
|
|
|
|
home = {
|
|
|
|
microserver = "fd7a:115c:a1e0:ab12:4843:cd96:6269:832f";
|
|
|
|
router = "fd7a:115c:a1e0:ab12:4843:cd96:6269:4730";
|
|
|
|
};
|
|
|
|
jakehillion-terminals = { gendry = "fd7a:115c:a1e0:ab12:4843:cd96:6246:644d"; };
|
|
|
|
lt = { be = "fd7a:115c:a1e0::9001:a64f"; };
|
|
|
|
pop = { li = "fd7a:115c:a1e0::e701:5723"; };
|
|
|
|
storage = {
|
|
|
|
theon = "fd7a:115c:a1e0::4aa8:8e16";
|
|
|
|
tywin = "fd7a:115c:a1e0:ab12:4843:cd96:6273:1f5b";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-11 22:24:35 +00:00
|
|
|
custom.dns.tailscale =
|
|
|
|
let
|
|
|
|
lookupFqdn = lib.attrsets.attrByPath (lib.reverseList (lib.splitString "." config.networking.fqdn)) null;
|
|
|
|
in
|
|
|
|
{
|
2024-04-27 17:06:20 +01:00
|
|
|
ipv4 = lookupFqdn cfg.authoritative.ipv4;
|
|
|
|
ipv6 = lookupFqdn cfg.authoritative.ipv6;
|
2024-02-11 22:24:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
networking.hosts =
|
|
|
|
let
|
|
|
|
mkHosts = hosts:
|
|
|
|
(lib.collect (x: (builtins.hasAttr "name" x && builtins.hasAttr "value" x))
|
|
|
|
(lib.mapAttrsRecursive
|
|
|
|
(path: value:
|
|
|
|
lib.nameValuePair value [ (lib.concatStringsSep "." (lib.reverseList path)) ])
|
|
|
|
hosts));
|
|
|
|
in
|
2024-04-27 17:06:20 +01:00
|
|
|
builtins.listToAttrs (mkHosts cfg.authoritative.ipv4 ++ mkHosts cfg.authoritative.ipv6);
|
2024-02-11 22:24:35 +00:00
|
|
|
};
|
|
|
|
}
|