1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 14:50:40 +02:00

feat(topology): render network addresses

This commit is contained in:
oddlama 2024-03-16 13:49:59 +01:00
parent 887115c96d
commit 25a864b1e8
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
8 changed files with 31 additions and 23 deletions

View file

@ -1,2 +0,0 @@
{
}

View file

@ -1,2 +0,0 @@
{
}

View file

@ -1,2 +0,0 @@
{
}

View file

@ -73,7 +73,7 @@ in {
network = networkId wgName;
virtual = true;
physicalConnections = flip map connectedPeers (peer: {
node = peer;
node = inputs.self.nodes.${peer}.config.topology.id;
interface = (wgCfgOf peer).linkName;
});
};

View file

@ -89,7 +89,7 @@ in
interface:
[
{
assertion = config.networks ? ${interface.network};
assertion = interface.network != null -> config.networks ? ${interface.network};
message = "topology: nodes.${node.id}.interfaces.${interface.id} refers to an unknown network '${interface.network}'";
}
]

View file

@ -8,6 +8,7 @@
(lib)
attrValues
concatLines
optionalString
;
#toD2 = _nodeName: node: ''
@ -29,25 +30,34 @@
#'';
netToD2 = net: ''
${net.id}: |md
# ${net.name}
${net.cidrv4}
${net.cidrv6}
|
${net.id}: ${net.name} {
info: |md
${net.cidrv4}
${net.cidrv6}
|
}
'';
nodeInterfaceToD2 = node: interface: ''
${node.id}.${interface.id}: |md
## ${interface.id}
|
${node.id}.${interface.id} -> ${interface.network}
'';
nodeInterfaceToD2 = node: interface:
''
${node.id}.${interface.id}: ${interface.id} {
info: |md
${toString interface.mac}
${toString interface.addresses}
${toString interface.gateways}
|
}
''
+ optionalString (interface.network != null) ''
${node.id}.${interface.id} -- ${interface.network}
'';
# TODO: deduplicate first
#+ concatLines (flip map interface.physicalConnections (x: ''
# ${node.id}.${interface.id} -- ${x.node}.${x.interface}
#''));
nodeToD2 = node: ''
${node.id}: |md
# ${node.name}
|
${node.id}: ${node.name} {}
${concatLines (map (nodeInterfaceToD2 node) (attrValues node.interfaces))}
'';