feat(dns): Split out config

This commit is contained in:
Tom Hubrecht 2024-02-23 12:20:12 +01:00
parent 9767dc35a0
commit 58c8d0f6d2
4 changed files with 38 additions and 47 deletions

View file

@ -63,6 +63,8 @@ in
import ./meta/nodes.nix
);
dns = import ./meta/dns.nix;
shells = {
default = pkgs.mkShell {
name = "dgnum-infra";

View file

@ -2,11 +2,8 @@
# Metadata for the nodes. You can add custom attributes, they are
# accessible through the specialArg meta in the config.
let
dns = args: import ./dns.nix (args // { inherit meta; });
meta =
lib:
(lib.evalModules {
modules = [
./options.nix
@ -17,9 +14,4 @@ let
}
];
class = "dgnumMeta";
}).config;
in
{
inherit dns meta;
}
}).config

View file

@ -1,35 +1,21 @@
{
lib,
meta,
dns,
...
}:
{ lib, dns, ... }:
let
inherit (lib) mapAttrs' nameValuePair;
inherit (lib.extra) fuseAttrs mapSingleFuse;
inherit (dns.lib.combinators) mx spf ttl;
meta' = meta lib;
meta = (import ./.) lib;
mkCNAME = host: { CNAME = [ host ]; };
mkRecord =
host:
let
net = meta'.network.${host};
in
{
A = net.addresses.publicV4;
AAAA = net.addresses.publicV6;
};
mkHosted = server: mapSingleFuse (_: mkCNAME "${server}.${meta'.nodes.${server}.site}.infra");
mkHosted = server: mapSingleFuse (_: mkCNAME "${server}.${meta.nodes.${server}.site}.infra");
cnames = builtins.mapAttrs (_: to: { CNAME = [ to ]; }) {
dev = "dev.pages.codeberg.page.";
irc = "public.p.lahfa.xyz.";
webmail = "kurisu.dual.lahfa.xyz.";
"dev" = "dev.pages.codeberg.page.";
"irc" = "public.p.lahfa.xyz.";
"webmail" = "kurisu.dual.lahfa.xyz.";
"*.cal" = "cal.dgnum.eu.";
"retired" = "web-static";
@ -108,10 +94,6 @@ let
)
);
infra.subdomains =
builtins.mapAttrs (_: nodes: { subdomains = mapSingleFuse mkRecord nodes; })
meta.infra;
kurisuDKIM = [
{
selector = "kurisu";
@ -164,12 +146,27 @@ in
};
}
// {
infra = infra // {
infra = {
MX = map (ttl 3600) [ (mx.mx 10 "kurisu.lahfa.xyz.") ];
TXT = [ (spf.strict [ "a:kurisu.lahfa.xyz" ]) ];
DMARC = [ { p = "none"; } ];
DKIM = kurisuDKIM;
subdomains =
mapAttrs'
(
host:
{ site, ... }:
nameValuePair "${host}.${site}" (
with meta.network.${host}.addresses;
{
A = ipv4;
AAAA = ipv6;
}
)
)
meta.nodes;
};
};
}

View file

@ -3,4 +3,4 @@ let
pkgs = import sources.nixpkgs { };
in
builtins.deepSeq ((import ./.).meta pkgs.lib) { }
builtins.deepSeq ((import ./.) pkgs.lib) { }