treewide: refactor code
This commit is contained in:
+23
-27
@@ -1,4 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.dns;
|
||||
|
||||
@@ -20,24 +25,17 @@ let
|
||||
subdomain = name: "subdomain ${name}";
|
||||
|
||||
zoneDomain =
|
||||
if lib.strings.hasSuffix ".key.age" filename then
|
||||
lib.strings.removeSuffix ".key.age" filename
|
||||
if strings.hasSuffix ".key.age" filename then
|
||||
strings.removeSuffix ".key.age" filename
|
||||
else
|
||||
throw "${filename} is not a `.key.age` file";
|
||||
in
|
||||
{
|
||||
inherit (config.age.secrets."dns/${filename}") path;
|
||||
name = zoneDomain;
|
||||
path = config.age.secrets."dns/${filename}".path;
|
||||
type = if zoneDomain == fqdn then zonesub else subdomain;
|
||||
}
|
||||
) agenixKeys;
|
||||
|
||||
cfg = config.dns;
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkOption
|
||||
mkIf
|
||||
;
|
||||
in
|
||||
{
|
||||
options.dns = {
|
||||
@@ -70,25 +68,20 @@ in
|
||||
|
||||
extraConfig = builtins.concatStringsSep "\n" (map (key: "include \"${key.path}\";") keys);
|
||||
|
||||
zones = {
|
||||
"${fqdn}" = {
|
||||
# grant "tuxcord.net" zonesub ANY;
|
||||
extraConfig = ''
|
||||
update-policy {
|
||||
${builtins.concatStringsSep "\n" (
|
||||
map (key: "grant \"${key.name}\" ${key.type key.name} ANY;") keys
|
||||
)}
|
||||
};
|
||||
'';
|
||||
file = "/var/dns/${fqdn}.zone"; # need to put default stuff
|
||||
master = true;
|
||||
};
|
||||
zones."${fqdn}" = {
|
||||
# grant "tuxcord.net" zonesub ANY;
|
||||
extraConfig = ''
|
||||
update-policy {
|
||||
${builtins.concatStringsSep "\n" (
|
||||
map (key: "grant \"${key.name}\" ${key.type key.name} ANY;") keys
|
||||
)}
|
||||
};
|
||||
'';
|
||||
file = "/var/dns/${fqdn}.zone"; # need to put default stuff
|
||||
master = true;
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ config.services.bind.listenOnPort ];
|
||||
networking.firewall.allowedUDPPorts = [ config.services.bind.listenOnPort ];
|
||||
|
||||
environment.persistence."/persist" = {
|
||||
directories = [
|
||||
{
|
||||
@@ -98,5 +91,8 @@ in
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ config.services.bind.listenOnPort ];
|
||||
networking.firewall.allowedUDPPorts = [ config.services.bind.listenOnPort ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user