{ pkgs, lib, config, nodes, ... }: with lib; { options.hpc.hostFile = { addresses = mkOption { description = '' IP addresses of this host ''; type = types.listOf types.str; default = let interface = config.networking.interfaces.${config.networking.defaultGateway.interface}; in concatLists [ (map (e: e.address) interface.ipv4.addresses) (map (e: e.address) interface.ipv6.addresses) ]; }; canonical = mkOption { description = '' Canonical host name ''; type = types.str; default = config.networking.fqdn; }; aliases = mkOption { description = '' Aliases for this host ''; type = types.listOf types.str; default = [ ]; }; entries = mkOption { description = '' Host name entries for this host ''; type = types.listOf types.str; readOnly = true; default = (singleton config.hpc.hostFile.canonical) ++ config.hpc.hostFile.aliases; }; }; config = { networking.hosts = listToAttrs (concatMap (node: map (address: nameValuePair address node.config.hpc.hostFile.entries) node.config.hpc.hostFile.addresses) (attrValues nodes)); }; }