treewide: migrate nixos modules to networking.hosts

Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
This commit is contained in:
John Titor 2025-06-04 20:55:03 +05:30 committed by Masum Reza
parent d859e3fcb9
commit cd64f1bd87
4 changed files with 27 additions and 27 deletions

View file

@ -3,15 +3,15 @@
let
inherit (lib)
attrNames
concatMap
concatMapAttrs
concatMapStrings
flip
forEach
head
listToAttrs
mkDefault
mkOption
nameValuePair
optionalAttrs
optionalString
range
toLower
@ -91,23 +91,22 @@ let
# interfaces, use the IP address corresponding to
# the first interface (i.e. the first network in its
# virtualisation.vlans option).
networking.extraHosts = flip concatMapStrings (attrNames nodes) (
m':
networking.hosts = concatMapAttrs (
name: config:
let
config = nodes.${m'};
hostnames =
optionalString (
config.networking.domain != null
) "${config.networking.hostName}.${config.networking.domain} "
+ "${config.networking.hostName}\n";
in
optionalString (
config.networking.primaryIPAddress != ""
) "${config.networking.primaryIPAddress} ${hostnames}"
+ optionalString (config.networking.primaryIPv6Address != "") (
"${config.networking.primaryIPv6Address} ${hostnames}"
)
);
optionalAttrs (config.networking.primaryIPAddress != "") {
"${config.networking.primaryIPAddress}" = [ hostnames ];
}
// optionalAttrs (config.networking.primaryIPv6Address != "") {
"${config.networking.primaryIPv6Address}" = [ hostnames ];
}
) nodes;
virtualisation.qemu.options = qemuOptions;
boot.initrd.services.udev.rules = concatMapStrings (x: x + "\n") udevRules;