2024-10-11 14:11:52 +02:00
|
|
|
{ pkgs, self, ... }:
|
|
|
|
rec {
|
2024-07-08 03:06:27 +02:00
|
|
|
octodns-zones =
|
|
|
|
let
|
2024-10-11 14:11:52 +02:00
|
|
|
nixosConfigModules = pkgs.lib.mapAttrsToList (
|
|
|
|
key: current:
|
|
|
|
# The iso image doesn't do any dns stuff
|
|
|
|
if key == "iso" then
|
|
|
|
{ }
|
|
|
|
else
|
|
|
|
# Copy over all dns records
|
|
|
|
{ satellite.dns = current.config.satellite.dns; }
|
|
|
|
) self.nixosConfigurations;
|
2024-07-08 03:06:27 +02:00
|
|
|
|
|
|
|
evaluated = pkgs.lib.evalModules {
|
2024-10-11 14:11:52 +02:00
|
|
|
specialArgs = {
|
|
|
|
inherit pkgs;
|
|
|
|
};
|
2024-07-08 03:06:27 +02:00
|
|
|
modules = [
|
|
|
|
../modules/nixos/dns.nix
|
|
|
|
../modules/common/octodns.nix
|
|
|
|
./common.nix
|
2024-10-11 14:11:52 +02:00
|
|
|
] ++ nixosConfigModules;
|
2024-07-08 03:06:27 +02:00
|
|
|
};
|
|
|
|
in
|
|
|
|
evaluated.config.satellite.dns.octodns;
|
|
|
|
|
2024-10-11 14:11:52 +02:00
|
|
|
octodns-sync = pkgs.symlinkJoin {
|
|
|
|
name = "octodns-sync";
|
|
|
|
paths = [ self.packages.${pkgs.system}.octodns ];
|
|
|
|
buildInputs = [
|
|
|
|
pkgs.makeWrapper
|
|
|
|
pkgs.yq
|
|
|
|
];
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
cat ${./octodns.yaml} | yq '.providers.zones.directory="${octodns-zones}"' > $out/config.yaml
|
|
|
|
wrapProgram $out/bin/octodns-sync \
|
|
|
|
--run 'export CLOUDFLARE_TOKEN=$( \
|
|
|
|
sops \
|
|
|
|
--decrypt \
|
|
|
|
--extract "[\"cloudflare_dns_api_token\"]" \
|
|
|
|
./hosts/nixos/common/secrets.yaml \
|
|
|
|
)' \
|
|
|
|
--add-flags "--config-file $out/config.yaml"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|