refactor(dns/network): replace dnsResolvableName with hostname and restructure DNS record generation

- Replaced `dnsResolvableName` with `hostname` in device configuration options
- Updated DNS record generation logic to use `hostname` instead of domain-based naming
- Removed deprecated `dnsResolvableName` option from network module
- Restructured DNS record templates to use consistent formatting
- Simplified code structure by removing redundant whitespace and reorganizing attribute definitions
- Updated `generateDeviceHostRecords` to use new naming convention and improved template syntax
This commit is contained in:
Giulio De Pasquale 2025-06-05 16:53:35 +01:00
parent 0e513e1c69
commit 184f039e40
2 changed files with 42 additions and 46 deletions

View File

@ -122,21 +122,22 @@ in
generateDeviceHostRecords =
let
generateRecordsForInterface = ifaceName: ifaceConfig:
lib.concatStringsSep "\n" (lib.mapAttrsToList (deviceName: deviceConfig:
if deviceConfig.dnsResolvableName != null then
lib.concatStringsSep "\n" (lib.mapAttrsToList
(deviceName: deviceConfig:
if deviceConfig.hostname!= null then
let
serverIP = deviceConfig.address;
interfaceNet = ifaceConfig.net;
domain = deviceConfig.dnsResolvableName;
deviceAddress = deviceConfig.address;
deviceIface = ifaceConfig.net;
deviceHost = deviceConfig.hostname;
in
''
${domain} {
${deviceHost} {
view ${ifaceName} {
expr incidr(client_ip(), '${interfaceNet}')
expr incidr(client_ip(), '${deviceIface}')
}
template IN A ${domain} {
answer "${domain}. 60 IN A ${serverIP}"
template IN A ${deviceHost} {
answer "${deviceHost}. 60 IN A ${deviceAddress}"
}
cache
@ -144,7 +145,8 @@ in
}
''
else ""
) ifaceConfig.devices);
)
ifaceConfig.devices);
in
lib.concatStringsSep "\n" (lib.mapAttrsToList generateRecordsForInterface config.pepe.core.network.interfaces);
in

View File

@ -42,12 +42,6 @@ in
default = false;
description = "Whether this device serves as a DNS endpoint for this interface.";
};
dnsResolvableName = mkOption {
type = types.nullOr types.str;
default = null;
description = "The fully qualified domain name that should resolve to this device's IP address. e.g., my-device.lan.example.com";
};
};
});
default = { };