Revert "treewide: migrate nixos modules to networking.hosts"

This reverts commit cd64f1bd874fbae5beaf0fcb39e05c2da75b16e1.

Changed files
+27 -27
nixos
lib
testing
modules
services
cluster
kubernetes
virtualisation
+12 -11
nixos/lib/testing/network.nix
···
let
inherit (lib)
attrNames
-
concatMapAttrs
concatMapStrings
forEach
head
listToAttrs
mkDefault
mkOption
nameValuePair
-
optionalAttrs
optionalString
range
toLower
···
# interfaces, use the IP address corresponding to
# the first interface (i.e. the first network in its
# virtualisation.vlans option).
-
networking.hosts = concatMapAttrs (
-
name: config:
let
hostnames =
optionalString (
config.networking.domain != null
) "${config.networking.hostName}.${config.networking.domain} "
+ "${config.networking.hostName}\n";
in
-
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;
···
let
inherit (lib)
attrNames
+
concatMap
concatMapStrings
+
flip
forEach
head
listToAttrs
mkDefault
mkOption
nameValuePair
optionalString
range
toLower
···
# 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':
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}"
+
)
+
);
virtualisation.qemu.options = qemuOptions;
boot.initrd.services.udev.rules = concatMapStrings (x: x + "\n") udevRules;
+3 -6
nixos/modules/services/cluster/kubernetes/pki.nix
···
keyFile = mkDefault key;
trustedCaFile = mkDefault caCert;
};
-
networking.hosts = mkIf (config.services.etcd.enable) {
-
"127.0.0.1" = [
-
"etcd.${top.addons.dns.clusterDomain}"
-
"etcd.local"
-
];
-
};
services.flannel = with cfg.certs.flannelClient; {
kubeconfig = top.lib.mkKubeConfig "flannel" {
···
keyFile = mkDefault key;
trustedCaFile = mkDefault caCert;
};
+
networking.extraHosts = mkIf (config.services.etcd.enable) ''
+
127.0.0.1 etcd.${top.addons.dns.clusterDomain} etcd.local
+
'';
services.flannel = with cfg.certs.flannelClient; {
kubeconfig = top.lib.mkKubeConfig "flannel" {
+4 -6
nixos/modules/virtualisation/google-compute-config.nix
···
# Rely on GCP's firewall instead
networking.firewall.enable = mkDefault false;
-
networking.hosts = {
-
"169.254.169.254" = [
-
"metadata.google.internal"
-
"metadata"
-
];
-
};
networking.timeServers = [ "metadata.google.internal" ];
···
# Rely on GCP's firewall instead
networking.firewall.enable = mkDefault false;
+
# Configure default metadata hostnames
+
networking.extraHosts = ''
+
169.254.169.254 metadata.google.internal metadata
+
'';
networking.timeServers = [ "metadata.google.internal" ];
+8 -4
nixos/modules/virtualisation/nixos-containers.nix
···
) config.containers;
# Generate /etc/hosts entries for the containers.
-
networking.hosts = lib.mapAttrs' (name: cfg: {
-
name = head (splitString "/" cfg.localAddress);
-
value = lib.optionals (cfg.localAddress != null) [ "${name}.containers" ];
-
}) config.containers;
networking.dhcpcd.denyInterfaces = [
"ve-*"
···
) config.containers;
# Generate /etc/hosts entries for the containers.
+
networking.extraHosts = concatStrings (
+
mapAttrsToList (
+
name: cfg:
+
optionalString (cfg.localAddress != null) ''
+
${head (splitString "/" cfg.localAddress)} ${name}.containers
+
''
+
) config.containers
+
);
networking.dhcpcd.denyInterfaces = [
"ve-*"