{ lib, config, ... }: let hostOptions = with lib; { ipv4 = mkOption { default = null; type = types.nullOr types.str; description = '' own ipv4 address ''; }; ipv6 = mkOption { type = types.nullOr types.str; default = null; description = '' own ipv6 address ''; }; }; in { options = with lib; { networking.newtype.hosts = mkOption { type = with types; attrsOf (submodule [{ options = hostOptions; }]); description = "A host in our cluster"; }; networking.newtype.currentHost = mkOption { type = with types; submodule [{ options = hostOptions; }]; default = config.networking.newtype.hosts.${config.networking.hostName}; description = "The host that is described by this configuration"; }; }; config = { warnings = lib.optional (!(config.networking.newtype.hosts ? ${config.networking.hostName}) && config.networking.hostName != "nixos" # we dont care about nixos netboot/installer images ) "Please add network configuration for ${config.networking.hostName}. None found in ${./hosts.nix}"; # usually, for each host there is a hostname.infra.newtype.fr networking.newtype.hosts = { epyc = { ipv6 = "2001:470:ca5e:dee:587c:7a50:f36c:cae8"; }; vieuxtype = { ipv6 = "2a01:e0a:5f9:9681:a498:fffb:e48d:299"; }; }; }; }