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:
parent
887115c96d
commit
25a864b1e8
8 changed files with 31 additions and 23 deletions
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -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;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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}'";
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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))}
|
||||
'';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue