From 01f37cec9fef1b56fd0fcf158ade484237567ac9 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 10 Nov 2021 20:12:45 +0100 Subject: [PATCH] lib/dns: add extraRecords --- nix/lib/config/options.nix | 19 ++++++++++++++++++- nix/lib/dns.nix | 8 +++++--- nix/nixos-module/container/dns.nix | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/nix/lib/config/options.nix b/nix/lib/config/options.nix index ee02ee4..3445fd7 100644 --- a/nix/lib/config/options.nix +++ b/nix/lib/config/options.nix @@ -159,7 +159,24 @@ let domainName = mkOption { description = "Domain name option"; type = types.str; - default = "${name}.zentralwerk.dn42"; + default = "${name}.zentralwerk.org"; + }; + extraRecords = mkOption { + type = with types; listOf (submodule { + options = { + name = mkOption { + type = str; + }; + type = mkOption { + type = enum [ "A" "AAAA" "MX" "SRV" "CNAME" "TXT" ]; + }; + data = mkOption { + type = str; + }; + }; + }); + default = []; + description = "Extraneous DNS records"; }; dynamicDomain = mkOption { type = types.bool; diff --git a/nix/lib/dns.nix b/nix/lib/dns.nix index f485f5c..83b0621 100644 --- a/nix/lib/dns.nix +++ b/nix/lib/dns.nix @@ -174,19 +174,21 @@ rec { } ]; } ] ++ builtins.concatLists ( builtins.attrValues ( - builtins.mapAttrs (net: { dynamicDomain, hosts4, hosts6, ... }: [ + builtins.mapAttrs (net: { dynamicDomain, hosts4, hosts6, extraRecords, ... }: [ { name = "${net}.zentralwerk.dn42"; ns = internalNS; records = - lib.optionals (hosts6 ? dn42) (hosts6Records hosts6.dn42); + lib.optionals (hosts6 ? dn42) (hosts6Records hosts6.dn42) ++ + extraRecords; } { name = "${net}.zentralwerk.org"; ns = publicNS; records = hosts4Records hosts4 ++ - lib.optionals (hosts6 ? up4) (hosts6Records hosts6.up4); + lib.optionals (hosts6 ? up4) (hosts6Records hosts6.up4) ++ + extraRecords; dynamic = dynamicDomain; } ]) namedNets diff --git a/nix/nixos-module/container/dns.nix b/nix/nixos-module/container/dns.nix index 9d7221b..bfba4ed 100644 --- a/nix/nixos-module/container/dns.nix +++ b/nix/nixos-module/container/dns.nix @@ -39,7 +39,7 @@ in type = types.str; }; type = mkOption { - type = types.enum [ "A" "AAAA" "PTR" ]; + type = types.enum [ "A" "AAAA" "MX" "SRV" "CNAME" "TXT" "PTR" ]; }; data = mkOption { type = types.str;