63 lines
1.5 KiB
Nix
63 lines
1.5 KiB
Nix
{ cluster, config, hosts, lib, tools, ... }:
|
|
|
|
let
|
|
inherit (hosts.${config.networking.hostName}) interfaces;
|
|
inherit (tools.meta) domain;
|
|
|
|
patroni = cluster.config.links.patroni-pg-access;
|
|
|
|
translateConfig = cfg: let
|
|
configList = lib.mapAttrsToList (n: v: "${n}=${v}") cfg;
|
|
in lib.concatStringsSep "\n" configList;
|
|
in {
|
|
links.localAuthoritativeDNS = {};
|
|
|
|
age.secrets = {
|
|
pdns-db-credentials = {
|
|
file = ./pdns-db-credentials.age;
|
|
mode = "0400";
|
|
owner = "pdns";
|
|
group = "pdns";
|
|
};
|
|
};
|
|
|
|
networking.firewall = {
|
|
allowedTCPPorts = [ 53 ];
|
|
allowedUDPPorts = [ 53 ];
|
|
};
|
|
|
|
services.powerdns = {
|
|
enable = true;
|
|
extraConfig = translateConfig {
|
|
launch = "gpgsql";
|
|
local-address = config.links.localAuthoritativeDNS.tuple;
|
|
gpgsql-host = patroni.ipv4;
|
|
gpgsql-port = patroni.portStr;
|
|
gpgsql-dbname = "powerdns";
|
|
gpgsql-user = "powerdns";
|
|
gpgsql-extra-connection-parameters = "passfile=${config.age.secrets.pdns-db-credentials.path}";
|
|
version-string = "Private Void DNS";
|
|
};
|
|
};
|
|
|
|
services.coredns = {
|
|
enable = true;
|
|
config = ''
|
|
. {
|
|
bind ${interfaces.primary.addr}
|
|
chaos "Private Void DNS" info@privatevoid.net
|
|
cache {
|
|
success 4000 86400
|
|
denial 0
|
|
prefetch 3
|
|
serve_stale 86400s
|
|
}
|
|
forward . ${config.links.localAuthoritativeDNS.tuple}
|
|
}
|
|
'';
|
|
};
|
|
|
|
systemd.services.coredns = {
|
|
after = [ "pdns.service" ];
|
|
};
|
|
}
|