1
Fork 0

Fix octodns setup

This commit is contained in:
prescientmoon 2024-10-11 14:11:52 +02:00
parent 78198f18b2
commit 404f6c8d3e
Signed by: prescientmoon
SSH key fingerprint: SHA256:WFp/cO76nbarETAoQcQXuV+0h7XJsEsOCI0UsyPIy6U
10 changed files with 238 additions and 178 deletions
modules/common

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
let
format = pkgs.formats.yaml { };
cfg = config.satellite.dns;
@ -12,32 +17,29 @@ in
config.satellite.dns.octodns =
let
grouped = builtins.groupBy (entry: entry.zone) cfg.records;
cpLines = lib.mapAttrsToList
(zone: group:
let
grouped = builtins.groupBy (entry: entry.at) group;
contents = lib.mapAttrs
(at: entries: lib.lists.forEach entries
(entry:
let
content =
if builtins.typeOf entry.value == "list"
then { values = entry.value; }
else { inherit (entry) value; };
cloudflare =
if entry.enableCloudflareProxy then {
octodns.cloudflare.proxied = true;
} else { };
in
{ inherit (entry) ttl type; }
// content // cloudflare
))
grouped;
file = format.generate "${zone}.yaml" contents;
in
"cp ${file} $out/${zone}.yaml"
)
grouped;
cpLines = lib.mapAttrsToList (
zone: group:
let
grouped = builtins.groupBy (entry: entry.at) group;
contents = lib.mapAttrs (
at: entries:
lib.lists.forEach entries (
entry:
let
content =
if builtins.typeOf entry.value == "list" then
{ values = entry.value; }
else
{ inherit (entry) value; };
cloudflare = if entry.enableCloudflareProxy then { octodns.cloudflare.proxied = true; } else { };
in
{ inherit (entry) ttl type; } // content // cloudflare
)
) grouped;
file = format.generate "${zone}.yaml" contents;
in
"cp ${file} $out/${zone}.yaml"
) grouped;
in
pkgs.runCommand "octodns-zones" { } ''
mkdir $out