mirror of
https://github.com/JulienMalka/snowfield.git
synced 2025-03-31 17:20:53 +02:00
feat: deploy nsd on akhaten
This commit is contained in:
parent
3f2bcbde15
commit
78e90e159e
2 changed files with 61 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
./home-julien.nix
|
./home-julien.nix
|
||||||
./stalwart.nix
|
./stalwart.nix
|
||||||
|
./nsd.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
machine.meta = {
|
machine.meta = {
|
||||||
|
|
60
machines/akhaten/nsd.nix
Normal file
60
machines/akhaten/nsd.nix
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
nixosConfigurations,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
zonesToList = lib.mapAttrsToList (name: value: { ${name} = value; });
|
||||||
|
zonesFromConfig = lib.mkMerge (
|
||||||
|
lib.fold (elem: acc: acc ++ (zonesToList elem.config.machine.meta.zones)) [ ] (
|
||||||
|
lib.attrValues nixosConfigurations
|
||||||
|
)
|
||||||
|
);
|
||||||
|
dnsLib = (import inputs.dns).lib;
|
||||||
|
evalZones =
|
||||||
|
zones:
|
||||||
|
(lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
zones = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf dnsLib.types.zone;
|
||||||
|
description = "DNS zones";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
inherit zones;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}).config.zones;
|
||||||
|
|
||||||
|
minimalZone = {
|
||||||
|
SOA = {
|
||||||
|
nameServer = "ns";
|
||||||
|
adminEmail = "dns@julienmalka.me";
|
||||||
|
serial = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
services.nsd = {
|
||||||
|
enable = true;
|
||||||
|
remoteControl.enable = true;
|
||||||
|
interfaces = [
|
||||||
|
config.machine.meta.ips.public.ipv4
|
||||||
|
config.machine.meta.ips.vpn.ipv4
|
||||||
|
];
|
||||||
|
zones = lib.mapAttrs (name: _: {
|
||||||
|
requestXFR = [ "AXFR ${lib.snowfield.gustave.ips.vpn.ipv4} NOKEY" ];
|
||||||
|
allowNotify = [ "${lib.snowfield.gustave.ips.vpn.ipv4} NOKEY" ];
|
||||||
|
data = dnsLib.toString name minimalZone;
|
||||||
|
}) (evalZones zonesFromConfig);
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.allowedUDPPorts = [ 53 ];
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue