forked from mirrors_public/oddlama_nix-config
feat(topology): render network addresses
This commit is contained in:
parent
887115c96d
commit
25a864b1e8
8 changed files with 31 additions and 23 deletions
3
modules/config/topology.nix
Normal file
3
modules/config/topology.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{config, ...}: {
|
||||||
|
topology.id = config.node.name;
|
||||||
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
./config/secrets.nix
|
./config/secrets.nix
|
||||||
./config/ssh.nix
|
./config/ssh.nix
|
||||||
./config/system.nix
|
./config/system.nix
|
||||||
|
./config/topology.nix
|
||||||
./config/users.nix
|
./config/users.nix
|
||||||
|
|
||||||
./acme-wildcard.nix
|
./acme-wildcard.nix
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
{
|
|
||||||
}
|
|
|
@ -73,7 +73,7 @@ in {
|
||||||
network = networkId wgName;
|
network = networkId wgName;
|
||||||
virtual = true;
|
virtual = true;
|
||||||
physicalConnections = flip map connectedPeers (peer: {
|
physicalConnections = flip map connectedPeers (peer: {
|
||||||
node = peer;
|
node = inputs.self.nodes.${peer}.config.topology.id;
|
||||||
interface = (wgCfgOf peer).linkName;
|
interface = (wgCfgOf peer).linkName;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,7 +89,7 @@ in
|
||||||
interface:
|
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}'";
|
message = "topology: nodes.${node.id}.interfaces.${interface.id} refers to an unknown network '${interface.network}'";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(lib)
|
(lib)
|
||||||
attrValues
|
attrValues
|
||||||
concatLines
|
concatLines
|
||||||
|
optionalString
|
||||||
;
|
;
|
||||||
|
|
||||||
#toD2 = _nodeName: node: ''
|
#toD2 = _nodeName: node: ''
|
||||||
|
@ -29,25 +30,34 @@
|
||||||
#'';
|
#'';
|
||||||
|
|
||||||
netToD2 = net: ''
|
netToD2 = net: ''
|
||||||
${net.id}: |md
|
${net.id}: ${net.name} {
|
||||||
# ${net.name}
|
info: |md
|
||||||
${net.cidrv4}
|
${net.cidrv4}
|
||||||
${net.cidrv6}
|
${net.cidrv6}
|
||||||
|
|
|
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nodeInterfaceToD2 = node: interface: ''
|
nodeInterfaceToD2 = node: interface:
|
||||||
${node.id}.${interface.id}: |md
|
''
|
||||||
## ${interface.id}
|
${node.id}.${interface.id}: ${interface.id} {
|
||||||
|
info: |md
|
||||||
|
${toString interface.mac}
|
||||||
|
${toString interface.addresses}
|
||||||
|
${toString interface.gateways}
|
||||||
|
|
|
|
||||||
|
}
|
||||||
${node.id}.${interface.id} -> ${interface.network}
|
''
|
||||||
|
+ 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: ''
|
nodeToD2 = node: ''
|
||||||
${node.id}: |md
|
${node.id}: ${node.name} {}
|
||||||
# ${node.name}
|
|
||||||
|
|
|
||||||
|
|
||||||
${concatLines (map (nodeInterfaceToD2 node) (attrValues node.interfaces))}
|
${concatLines (map (nodeInterfaceToD2 node) (attrValues node.interfaces))}
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue