dns: go back to basically an earlier config

This commit is contained in:
silver 2023-04-29 02:35:58 +01:00
parent ec8b458d75
commit d750b046d1

View file

@ -2,20 +2,9 @@
let let
cfg = config.skynet_dns; cfg = config.skynet_dns;
# writes current epoch to a file (will need to be fixed in 2038) # reads that date to a string (will need to be fixed in 2038)
current_date_path = pkgs.runCommand "current_date" {} "date '+%s' > $out"; current_date = toString builtins.currentTime;
# reads that date to a string
current_date = (lib.readFile current_date_path);
# get all the records as a string (used later in teh zone file)
current_external = lib.strings.concatMapStrings (x: x + "\n") cfg.records.external;
current_cname = lib.strings.concatMapStrings (x: x + "\n") cfg.records.cname;
# get a hash of these two (cut down into a more manageable size)
current_hash = lib.substring 0 10 (builtins.hashString "md5" "${current_external}_${current_cname}");
# create a custom filepath
current_file = "${current_date}_${current_hash}";
in { in {
options = { options = {
skynet_dns = { skynet_dns = {
@ -141,13 +130,16 @@ in {
dnssec-policy default; dnssec-policy default;
inline-signing yes; inline-signing yes;
// for bumping the config
// ${current_date}
''; '';
# really wish teh nixos config didnt use master/slave # really wish teh nixos config didnt use master/slave
master = true; master = true;
slaves = [ ]; slaves = [ ];
# need to write this to a file # need to write this to a file
# using the date in it so it will trigger a restart # using the date in it so it will trigger a restart
file = "/etc/dns_custom/dns_zone_skynet_${current_file}"; file = "/etc/dns_custom/dns_zone_skynet";
# no leading whitespace for first line # no leading whitespace for first line
}; };
@ -163,7 +155,7 @@ in {
environment.etc = { environment.etc = {
# Creates /etc/dns_custom/dns_zone_skynet # Creates /etc/dns_custom/dns_zone_skynet
"dns_custom/dns_zone_skynet_${current_file}" = { "dns_custom/dns_zone_skynet" = {
user = "named"; user = "named";
group = "named"; group = "named";
@ -200,7 +192,7 @@ in {
; External addresses ; External addresses
; ------------------------------------------ ; ------------------------------------------
${current_external} ${lib.strings.concatMapStrings (x: x + "\n") cfg.records.external}
; this is fixed for now ; this is fixed for now
@ -215,7 +207,7 @@ in {
; cname's ; cname's
; ------------------------------------------ ; ------------------------------------------
${current_cname} ${lib.strings.concatMapStrings (x: x + "\n") cfg.records.cname}
''; '';
}; };