DEVELOPMENT ENVIRONMENT

~liljamo/nix-arta

b6b039dab59bf7ee6f0856bb5e2953de9d7b1a58 — Jonni Liljamo 2 months ago 89ec3f6
feat(lib/util): more functions
1 files changed, 10 insertions(+), 6 deletions(-)

M lib/util.nix
M lib/util.nix => lib/util.nix +10 -6
@@ 14,15 14,19 @@
    };
  };

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

  # hostname.home.arpa = ip
  hostnameDNSEntries =
  # getHostnames "profile"
  getHostnames = profile: builtins.attrNames hostnameIPv4.${profile};

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