Commit cd64f1bd authored by John Titor's avatar John Titor Committed by Masum Reza
Browse files

treewide: migrate nixos modules to networking.hosts

parent d859e3fc
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -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;
+6 −3
Original line number Diff line number Diff line
@@ -365,9 +365,12 @@ in
        keyFile = mkDefault key;
        trustedCaFile = mkDefault caCert;
      };
      networking.extraHosts = mkIf (config.services.etcd.enable) ''
        127.0.0.1 etcd.${top.addons.dns.clusterDomain} etcd.local
      '';
      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" {
+6 −4
Original line number Diff line number Diff line
@@ -70,10 +70,12 @@ in
  # 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.hosts = {
    "169.254.169.254" = [
      "metadata.google.internal"
      "metadata"
    ];
  };

  networking.timeServers = [ "metadata.google.internal" ];

+4 −8
Original line number Diff line number Diff line
@@ -1084,14 +1084,10 @@ in
          ) 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.hosts = lib.mapAttrs' (name: cfg: {
          name = head (splitString "/" cfg.localAddress);
          value = lib.optionals (cfg.localAddress != null) [ "${name}.containers" ];
        }) config.containers;

        networking.dhcpcd.denyInterfaces = [
          "ve-*"