central IP

This commit is contained in:
nora 2024-07-31 20:05:02 +02:00
parent 59ec8ef37b
commit cfe47e65c0
4 changed files with 42 additions and 28 deletions

View file

@ -1,18 +1,16 @@
# https://github.com/nix-community/dns.nix
{ pkgs, lib, ... }:
{ pkgs, lib, networkingConfig, ... }:
let
data = with pkgs.nix-dns.lib.combinators;
let
hour1 = 3600;
normalHost = ipv4: ipv6:
lib.optionalAttrs (ipv4 != null) { A = [ (ttl hour1 (a ipv4)) ]; } //
lib.optionalAttrs (ipv6 != null) { AAAA = [ (ttl hour1 (aaaa ipv6)) ]; };
dns1 = normalHost "154.38.163.74" null;
dns2 = normalHost "128.140.3.7" "2a01:4f8:c2c:d616::";
vps1 = normalHost "161.97.165.1" null;
vps3 = normalHost "134.255.181.139" null;
hostsToDns = builtins.mapAttrs
(name: { publicIPv4, publicIPv6 }:
lib.optionalAttrs (publicIPv4 != null) { A = [ (ttl hour1 (a publicIPv4)) ]; } //
lib.optionalAttrs (publicIPv6 != null) { AAAA = [ (ttl hour1 (aaaa publicIPv6)) ]; })
networkingConfig;
in
with hostsToDns;
# vps1 contains root noratrieb.dev
vps1 // {
SOA = {
@ -37,17 +35,12 @@ let
localhost.A = [ (a "127.0.0.1") ];
newtest.TXT = [ "uwu it works" ];
# TODO: generate dynamically from IPs...
infra.subdomains = {
inherit dns1;
inherit dns2;
inherit vps1;
inherit vps3;
};
infra.subdomains = hostsToDns;
};
};
in
pkgs.writeTextFile {
pkgs.writeTextFile
{
name = "noratrieb.dev.zone";
text = pkgs.nix-dns.lib.toString "noratrieb.dev" data;
}