DEVELOPMENT ENVIRONMENT

~liljamo/nix-arta

89ec3f61c9869ae1e7c489cdf8e191a7b3e90793 — Jonni Liljamo 2 months ago 5e3bf6e
feat: small tweak to util ip mapping
3 files changed, 20 insertions(+), 11 deletions(-)

M lib/util.nix
M systems/profiles/lxc/lxc.nix
M systems/profiles/vm/vm.nix
M lib/util.nix => lib/util.nix +18 -9
@@ 1,19 1,28 @@
{lib, ...}: let
  hostnameIPv4 = {
    "sqbuilds" = "10.1.1.50";
    "dns" = "10.1.2.3";
    "metrics" = "10.1.2.5";
    "proxy" = "10.1.2.10";
    "auth" = "10.1.2.12";
    "cloud" = "10.1.2.15";
    "social" = "10.1.2.17";
    vm = {
      "sqbuilds" = "10.1.1.50";
    };

    lxc = {
      "dns" = "10.1.2.3";
      "metrics" = "10.1.2.5";
      "proxy" = "10.1.2.10";
      "auth" = "10.1.2.12";
      "cloud" = "10.1.2.15";
      "social" = "10.1.2.17";
    };
  };
  getIPv4 = hostName: hostnameIPv4.${hostName};
in {

  # getIPv4 "type" "hostname"
  getIPv4 = type: hostname: hostnameIPv4.${type}.${hostname};

  # hostname.home.arpa = ip
  hostnameDNSEntries =
    lib.attrsets.mapAttrs'
    (name: value: lib.attrsets.nameValuePair (name + ".home.arpa") value)
    hostnameIPv4;
in {
  getIPv4 = getIPv4;
  hostnameDNSEntries = hostnameDNSEntries;
}

M systems/profiles/lxc/lxc.nix => systems/profiles/lxc/lxc.nix +1 -1
@@ 23,7 23,7 @@
  networking.nameservers = ["10.1.2.3"];
  networking.interfaces."eth0".ipv4.addresses = [
    {
      address = artautil.getIPv4 config.networking.hostName;
      address = artautil.getIPv4 "lxc" config.networking.hostName;
      prefixLength = 24;
    }
  ];

M systems/profiles/vm/vm.nix => systems/profiles/vm/vm.nix +1 -1
@@ 23,7 23,7 @@
  /*
  networking.interfaces."eth0".ipv4.addresses = [
    {
      address = artautil.getIPv4 config.networking.hostName;
      address = artautil.getIPv4 "vm" config.networking.hostName;
      prefixLength = 24;
    }
  ];