infrastructure/meta/dns.nix

197 lines
4.3 KiB
Nix
Raw Normal View History

2024-02-23 12:20:12 +01:00
{ lib, dns, ... }:
2024-01-31 15:27:26 +01:00
let
2024-02-23 12:20:12 +01:00
inherit (lib) mapAttrs' nameValuePair;
2024-01-31 15:27:26 +01:00
inherit (lib.extra) fuseAttrs mapSingleFuse;
inherit (dns.lib.combinators) mx spf ttl;
2024-02-23 12:20:12 +01:00
meta = (import ./.) lib;
2024-02-23 10:50:50 +01:00
2024-01-31 15:27:26 +01:00
mkCNAME = host: { CNAME = [ host ]; };
2024-03-29 11:41:13 +01:00
mkHosted =
server:
{
dual ? [ ],
v4 ? [ ],
v6 ? [ ],
}:
let
base = "${server}.${meta.nodes.${server}.site}.infra";
mkHost = host: mapSingleFuse (_: mkCNAME host);
in
fuseAttrs [
(mkHost base dual)
(mkHost "v4.${base}" v4)
(mkHost "v6.${base}" v6)
];
2024-01-31 15:27:26 +01:00
cnames = builtins.mapAttrs (_: to: { CNAME = [ to ]; }) {
2024-02-23 12:20:12 +01:00
"dev" = "dev.pages.codeberg.page.";
"irc" = "public.p.lahfa.xyz.";
"webmail" = "kurisu.dual.lahfa.xyz.";
# Transition to new site names
"web01.dmi01.infra" = "web01.rat01.infra";
"web02.dmi01.infra" = "web02.rat01.infra";
"compute01.par01.infra" = "compute01.pav01.infra";
"storage01.par01.infra" = "storage01.pav01.infra";
2024-01-31 15:27:26 +01:00
};
hosted = fuseAttrs (
builtins.attrValues (
builtins.mapAttrs mkHosted {
2024-03-29 11:41:13 +01:00
compute01.dual = [
2024-03-08 11:07:19 +01:00
"arkheon" # Arkheon
2024-02-23 13:44:16 +01:00
"cloud" # Nextcloud
"code" # Collabora Online
"demarches" # Démarches Normaliennes
"docs" # Outline
"grafana" # Grafana
"nms" # LibreNMS
"pads" # Hedgedoc
"pass" # Vaultwarden
"pdf" # Stirling PDF
2024-02-23 13:44:16 +01:00
"saml-idp" # Satosa
"social" # Mastodon
"sso" # Kanidm
"support" # Zammad support
"telegraf" # Telegraf
2024-01-31 15:27:26 +01:00
];
2024-03-29 11:41:13 +01:00
storage01.dual = [
2024-02-23 13:44:16 +01:00
"cachix" # Attic
"git" # Forgejo
"influx" # InfluxDB
"netbird" # Netbird
"prometheus" # Prometheus
"videos" # Peertube
2024-01-31 15:27:26 +01:00
# Garage S3
"*.cdn"
"*.s3"
2024-02-23 13:44:16 +01:00
"cdn"
"s3"
2024-01-31 15:27:26 +01:00
];
2024-04-04 13:36:41 +02:00
rescue01.dual = [
"status" # Uptime Kuma
];
2024-03-29 11:41:13 +01:00
web01.dual = [
2024-02-23 13:44:16 +01:00
"*.wp" # Wordpress
"analytics" # Plausible Analytics
"calendrier" # Metis
"netbox" # Netbox
"podcasts" # Castopod
"push" # Ntfy.sh
# Static websites
"eleves"
"migrated.rz"
"qr"
"retired"
"web-static"
2024-01-31 15:27:26 +01:00
# Linkal
"*.cal"
"cal"
"linkal"
2024-02-23 13:44:16 +01:00
2024-01-31 15:27:26 +01:00
# Crab Fit
"api.meet"
"meet"
2024-02-23 13:44:16 +01:00
"rdv" # C.f. loi Toubon
2024-01-31 15:27:26 +01:00
];
}
)
);
kurisuDKIM = [
{
selector = "kurisu";
k = "rsa";
s = [ "email" ];
p = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDa5KuK6ry+Ss2VsKL0FsDpoBlc7dcXZyp62fGqFJFJv4/GEivPWiwbr2o5oLKjQVI4kIYjIZsyQJFtI/Xcu4BrtDdBknb5WvCN8V9EvIMh3pfXOBLVx4oqw4BR7wF8Rw1J9xyfgsfK+m2n0M39XlMHH0Nuy6kU48jH9vYpZs17ZQIDAQAB";
}
];
in
{
2024-01-31 15:46:31 +01:00
SOA = {
nameServer = "ns01.dgnum.eu.";
adminEmail = "dns.dgnum.eu";
retry = 3600;
minimum = 300;
};
2024-01-31 15:27:26 +01:00
# Primary DNS servers
NS = [
"ns01.dgnum.eu." # ns-03.hubrecht.ovh
"ns02.dgnum.eu." # kurisu.lahfa.xyz
2024-01-31 15:27:26 +01:00
];
# dgnum.codeberg.pages
# ALIAS = [ "codeberg.page" ];
A = [ "217.197.91.145" ];
AAAA = [ "2001:67c:1401:20f0::1" ];
MX = map (ttl 3600) [ (mx.mx 10 "kurisu.lahfa.xyz.") ];
2024-02-23 14:16:07 +01:00
SRV = [
{
service = "autodiscover";
proto = "tcp";
port = 443;
target = "autoconfig.mail.lahfa.xyz.";
}
];
2024-01-31 15:27:26 +01:00
TXT = [
"dgnum.codeberg.page"
(spf.strict [ "a:kurisu.lahfa.xyz" ])
];
DMARC = [ { p = "none"; } ];
DKIM = kurisuDKIM;
subdomains =
hosted
// cnames
// {
ns01 = {
A = [ "51.178.27.125" ];
AAAA = [ "2001:41d0:305:2100::542c" ];
};
ns02 = {
A = [ "163.172.69.160" ];
AAAA = [ "2001:bc8:38ee::1" ];
};
2024-01-31 15:27:26 +01:00
}
// {
2024-02-23 12:20:12 +01:00
infra = {
2024-01-31 15:27:26 +01:00
MX = map (ttl 3600) [ (mx.mx 10 "kurisu.lahfa.xyz.") ];
TXT = [ (spf.strict [ "a:kurisu.lahfa.xyz" ]) ];
DMARC = [ { p = "none"; } ];
DKIM = kurisuDKIM;
2024-02-23 12:20:12 +01:00
subdomains = mapAttrs' (
host:
{ site, ... }:
nameValuePair "${host}.${site}" (
with meta.network.${host}.addresses;
{
A = ipv4;
AAAA = ipv6;
2024-03-29 11:41:13 +01:00
subdomains = {
v4.A = ipv4;
v6.AAAA = ipv6;
};
}
)
) meta.nodes;
2024-01-31 15:27:26 +01:00
};
};
}