chore(access): network.networks.global

This commit is contained in:
arcnmx 2025-09-06 21:40:48 -07:00
parent 4662495775
commit dd30009b7e
5 changed files with 44 additions and 3 deletions

View file

@ -3,6 +3,7 @@
"network": { "network": {
"hostName": "aya", "hostName": "aya",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.73", "address4": "10.9.1.73",
"address6": "fd0c::49", "address6": "fd0c::49",
@ -25,6 +26,7 @@
"network": { "network": {
"hostName": "chen", "hostName": "chen",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": null, "address4": null,
@ -39,6 +41,7 @@
"network": { "network": {
"hostName": "ct", "hostName": "ct",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": null, "address4": null,
@ -53,6 +56,7 @@
"network": { "network": {
"hostName": "extern-test", "hostName": "extern-test",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": null, "local": null,
"tail": null "tail": null
@ -63,6 +67,7 @@
"network": { "network": {
"hostName": "idp", "hostName": "idp",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.170", "address4": "10.9.1.170",
"address6": "fd0c::aa", "address6": "fd0c::aa",
@ -81,6 +86,7 @@
"network": { "network": {
"hostName": "freepbx", "hostName": "freepbx",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.43", "address4": "10.1.1.43",
@ -95,6 +101,7 @@
"network": { "network": {
"hostName": "gengetsu", "hostName": "gengetsu",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.61", "address4": "10.1.1.61",
@ -109,6 +116,7 @@
"network": { "network": {
"hostName": "hakurei", "hostName": "hakurei",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.71", "address4": "10.9.1.71",
"address6": "fd0c::47", "address6": "fd0c::47",
@ -131,6 +139,7 @@
"network": { "network": {
"hostName": "idrac-gengetsu", "hostName": "idrac-gengetsu",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.12", "address4": "10.1.1.12",
@ -145,6 +154,7 @@
"network": { "network": {
"hostName": "idrac-mugetsu", "hostName": "idrac-mugetsu",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.13", "address4": "10.1.1.13",
@ -159,6 +169,7 @@
"network": { "network": {
"hostName": "kasen", "hostName": "kasen",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.49", "address4": "10.1.1.49",
@ -177,6 +188,7 @@
"network": { "network": {
"hostName": "keycloak", "hostName": "keycloak",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.75", "address4": "10.9.1.75",
"address6": "fd0c::4b", "address6": "fd0c::4b",
@ -195,6 +207,7 @@
"network": { "network": {
"hostName": "kitchencam", "hostName": "kitchencam",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": null, "address4": null,
@ -209,6 +222,7 @@
"network": { "network": {
"hostName": "koishi", "hostName": "koishi",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.68", "address4": "10.1.1.68",
@ -223,6 +237,7 @@
"network": { "network": {
"hostName": "kuwubernetes", "hostName": "kuwubernetes",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.42", "address4": "10.1.1.42",
@ -237,6 +252,7 @@
"network": { "network": {
"hostName": "kvm-reisen", "hostName": "kvm-reisen",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.9", "address4": "10.1.1.9",
@ -255,6 +271,7 @@
"network": { "network": {
"hostName": "litterbox", "hostName": "litterbox",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.74", "address4": "10.9.1.74",
"address6": "fd0c::4a", "address6": "fd0c::4a",
@ -277,6 +294,7 @@
"network": { "network": {
"hostName": "logistics", "hostName": "logistics",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.63", "address4": "10.1.1.63",
@ -291,6 +309,7 @@
"network": { "network": {
"hostName": "mediabox", "hostName": "mediabox",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.70", "address4": "10.9.1.70",
"address6": "fd0c::46", "address6": "fd0c::46",
@ -313,6 +332,7 @@
"network": { "network": {
"hostName": "minecraft", "hostName": "minecraft",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.51", "address4": "10.1.1.51",
@ -331,6 +351,7 @@
"network": { "network": {
"hostName": "mugetsu", "hostName": "mugetsu",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.60", "address4": "10.1.1.60",
@ -345,6 +366,7 @@
"network": { "network": {
"hostName": "nue", "hostName": "nue",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.62", "address4": "10.1.1.62",
@ -363,6 +385,7 @@
"network": { "network": {
"hostName": "reimu", "hostName": "reimu",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.72", "address4": "10.9.1.72",
"address6": "fd0c::48", "address6": "fd0c::48",
@ -385,6 +408,7 @@
"network": { "network": {
"hostName": "reisen", "hostName": "reisen",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.2", "address4": "10.9.1.2",
"address6": "fd0c::2", "address6": "fd0c::2",
@ -403,6 +427,7 @@
"network": { "network": {
"hostName": "sakuya", "hostName": "sakuya",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.50", "address4": "10.1.1.50",
@ -421,6 +446,7 @@
"network": { "network": {
"hostName": "shanghai", "hostName": "shanghai",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.32", "address4": "10.1.1.32",
@ -439,6 +465,7 @@
"network": { "network": {
"hostName": "tei", "hostName": "tei",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.69", "address4": "10.9.1.69",
"address6": "fd0c::45", "address6": "fd0c::45",
@ -461,6 +488,7 @@
"network": { "network": {
"hostName": "tewi", "hostName": "tewi",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": null, "address4": null,
@ -479,6 +507,7 @@
"network": { "network": {
"hostName": "u7-pro", "hostName": "u7-pro",
"networks": { "networks": {
"global": null,
"int": null, "int": null,
"local": { "local": {
"address4": "10.1.1.3", "address4": "10.1.1.3",
@ -493,6 +522,7 @@
"network": { "network": {
"hostName": "utsuho", "hostName": "utsuho",
"networks": { "networks": {
"global": null,
"int": { "int": {
"address4": "10.9.1.76", "address4": "10.9.1.76",
"address6": "fd0c::4c", "address6": "fd0c::4c",

View file

@ -75,6 +75,7 @@
int = null; int = null;
local = null; local = null;
tail = null; tail = null;
global = null;
} }
// mapAttrs' (_: network: // mapAttrs' (_: network:
nameValuePair network.name { nameValuePair network.name {

View file

@ -53,7 +53,10 @@
fallback = fallback =
if nameAllowed if nameAllowed
then lib.warn "getAddressFor hostname fallback for ${config.networking.hostName} -> ${hostName}@${network}" (access.getHostnameFor hostName network) then lib.warn "getAddressFor hostname fallback for ${config.networking.hostName} -> ${hostName}@${network}" (access.getHostnameFor hostName network)
else if forSystem.access.global.enable
then lib.warn "getAddressFor global fallback for ${config.networking.hostName} -> ${hostName}@${network}" (mkGetAddressFor true addressForAttr hostName "global")
else err; else err;
global = forSystem.access.${addressForAttr}.global or forSystem.access.address4ForNetwork.global or fallback;
local = forSystem.access.${addressForAttr}.local or forSystem.access.address4ForNetwork.local or fallback; local = forSystem.access.${addressForAttr}.local or forSystem.access.address4ForNetwork.local or fallback;
int = forSystem.access.${addressForAttr}.int or forSystem.access.address4ForNetwork.int or fallback; int = forSystem.access.${addressForAttr}.int or forSystem.access.address4ForNetwork.int or fallback;
tail = forSystem.access.${addressForAttr}.tail or fallback; tail = forSystem.access.${addressForAttr}.tail or fallback;
@ -66,6 +69,8 @@
then int then int
else if has'Local && forSystemHas "local" else if has'Local && forSystemHas "local"
then local then local
else if forSystem.access.global.enable && forSystemHas "global"
then global
else fallback; else fallback;
${ ${
if has'Local if has'Local
@ -85,6 +90,7 @@
else null else null
} = } =
tail; tail;
global = global;
} }
.${network} .${network}
or fallback; or fallback;

View file

@ -20,6 +20,7 @@
prefix = "fd0a:"; prefix = "fd0a:";
}; };
int.slaac.prefix = "fd0c:"; int.slaac.prefix = "fd0c:";
global.domain = systemConfig.access.domain;
}; };
in { in {
options = with lib.types; { options = with lib.types; {
@ -68,7 +69,7 @@
); );
postfix = mkIf (config.macAddress != null) (mkOptionDefault (eui64 config.macAddress)); postfix = mkIf (config.macAddress != null) (mkOptionDefault (eui64 config.macAddress));
}; };
domain = mkOptionDefault "${config.name}.${systemConfig.access.domain}"; domain = mkOptionDefault knownNetworks.${config.name}.domain or "${config.name}.${systemConfig.access.domain}";
fqdn = mkOptionDefault (mapNullable (domain: "${systemConfig.access.hostName}.${domain}") config.domain); fqdn = mkOptionDefault (mapNullable (domain: "${systemConfig.access.hostName}.${domain}") config.domain);
address6 = mkIf config.slaac.enable (mkOptionDefault "${config.slaac.prefix}:${config.slaac.postfix}"); address6 = mkIf config.slaac.enable (mkOptionDefault "${config.slaac.prefix}:${config.slaac.postfix}");
}; };

View file

@ -98,6 +98,9 @@ locals {
tailscale_v4 = coalesce(var.tailscale_v4, local.tailscale_net.address4, local.empty_address) tailscale_v4 = coalesce(var.tailscale_v4, local.tailscale_net.address4, local.empty_address)
tailscale_v6 = coalesce(var.tailscale_v6, local.tailscale_net.address6, local.empty_address) tailscale_v6 = coalesce(var.tailscale_v6, local.tailscale_net.address6, local.empty_address)
global_name = coalesce(var.global_name, local.name) global_name = coalesce(var.global_name, local.name)
global_net = coalesce(var.net_data.networks.global, local.empty_net)
global_v4 = coalesce(var.global_v4, local.global_net.address4, local.empty_address)
global_v6 = coalesce(var.global_v6, local.global_net.address6, local.empty_address)
has_tailscale = local.tailscale_v4 != local.empty_address || local.tailscale_v6 != local.empty_address has_tailscale = local.tailscale_v4 != local.empty_address || local.tailscale_v6 != local.empty_address
has_int = local.int_v4 != local.empty_address || local.int_v6 != local.empty_address has_int = local.int_v4 != local.empty_address || local.int_v6 != local.empty_address
@ -114,7 +117,7 @@ locals {
}, },
{ {
name = local.global_name, name = local.global_name,
value = var.global_v4, value = local.global_v4,
}, },
{ {
name = local.int_name, name = local.int_name,
@ -133,7 +136,7 @@ locals {
}, },
{ {
name = local.global_name, name = local.global_name,
value = var.global_v6, value = local.global_v6,
}, },
{ {
name = local.int_name, name = local.int_name,