topology: localize nixos module, add custom extractor, fix misc

This commit is contained in:
h7x4
2025-12-30 02:01:10 +09:00
parent 58be01e620
commit 197433a4c3
4 changed files with 93 additions and 31 deletions

149
topology/default.nix Normal file
View File

@@ -0,0 +1,149 @@
{ lib, config, ... }:
let
inherit
(config.lib.topology)
mkInternet
mkRouter
mkSwitch
mkDevice
mkConnection
mkConnectionRev;
values = import ../values.nix;
in {
### Networks
networks.pvv = {
name = "PVV Network";
cidrv4 = values.ipv4-space;
cidrv6 = values.ipv6-space;
};
networks.site-vpn = {
name = "OpenVPN Site to Site";
style = {
primaryColor = "#9dd68d";
secondaryColor = null;
pattern = "dashed";
};
};
networks.ntnu = {
name = "NTNU";
};
nodes.internet = mkInternet {
connections = mkConnection "ntnu" "wan1";
};
nodes.ntnu = mkRouter "NTNU" {
interfaceGroups = [ ["wan1"] ["eth1" "eth2" "eth3"] ];
connections.eth1 = mkConnection "ntnu-pvv-router" "wan1";
connections.eth2 = mkConnection "ntnu-veggen" "wan1";
connections.eth3 = mkConnection "stackit" "*";
interfaces.eth1.network = "ntnu";
};
### Brus
nodes.ntnu-pvv-router = mkRouter "NTNU PVV Gateway" {
interfaceGroups = [ ["wan1"] ["eth1"] ];
connections.eth1 = mkConnection "brus-switch" "eth1";
interfaces.eth1.network = "pvv";
};
nodes.brus-switch = mkSwitch "Brus Switch" {
interfaceGroups = [ (lib.genList (i: "eth${toString i}") 16) ];
connections.eth2 = mkConnection "bekkalokk" "enp2s0";
# connections.eth3 = mkConnection "bicep" "enp6s0f0";
connections.eth4 = mkConnection "buskerud" "eth1";
connections.eth5 = mkConnection "knutsen" "eth1";
connections.eth6 = mkConnection "powerpuff-cluster" "eth1";
connections.eth8 = mkConnection "lupine-1" "enp0s31f6";
connections.eth9 = mkConnection "lupine-2" "enp0s31f6";
connections.eth11 = mkConnection "lupine-3" "enp0s31f6";
connections.eth10 = mkConnection "lupine-4" "enp0s31f6";
connections.eth12 = mkConnection "lupine-5" "enp0s31f6";
};
nodes.knutsen = mkRouter "knutsen" {
interfaceGroups = [ ["eth1"] ["eth2"] ["vpn1"] ];
connections.eth2 = mkConnectionRev "brus-switch" "eth6";
# connections.vpn1 = mkConnection "ludvigsen" "vpn1";
interfaces.vpn1.network = "site-vpn";
interfaces.vpn1.virtual = true;
};
nodes.buskerud = mkDevice "buskerud" {
interfaceGroups = [ ["eth1"] ];
};
nodes.shark = {
guestType = "proxmox";
parent = config.nodes.buskerud.id;
};
### Powerpuff
nodes.powerpuff-cluster = mkDevice "powerpuff-cluster" {
interfaceGroups = [ ["eth1"] ];
};
nodes.kommode = {
guestType = "proxmox";
parent = config.nodes.powerpuff-cluster.id;
};
nodes.bicep = {
guestType = "proxmox";
parent = config.nodes.powerpuff-cluster.id;
};
nodes.ustetind = {
guestType = "proxmox";
parent = config.nodes.powerpuff-cluster.id;
};
### PVV
nodes.ntnu-veggen = mkRouter "NTNU-Veggen" {
interfaceGroups = [ ["wan1"] ["eth1"] ];
connections.eth1 = mkConnection "ludvigsen" "eth1";
};
nodes.ludvigsen = mkRouter "ludvigsen" {
interfaceGroups = [ ["eth1"] ["eth2"] ["vpn1"] ];
connections.eth2 = mkConnection "pvv-switch" "eth1";
interfaces.vpn1.network = "site-vpn";
interfaces.vpn1.virtual = true;
interfaces.eth1.network = "ntnu";
interfaces.eth2.network = "pvv";
};
nodes.pvv-switch = mkSwitch "PVV Switch (Terminalrommet)" {
interfaceGroups = [ ["eth1" "eth2" "eth3"] ];
connections.eth2 = mkConnection "brzeczyszczykiewicz" "eno1";
connections.eth3 = mkConnection "georg" "eno1";
};
### Openstack
nodes.stackit = mkDevice "stackit" {
interfaceGroups = [ ["*"] ];
};
nodes.ildkule = {
guestType = "openstack";
parent = config.nodes.stackit.id;
};
nodes.wenche = {
guestType = "openstack";
parent = config.nodes.stackit.id;
};
nodes.bakke = {
guestType = "openstack";
parent = config.nodes.stackit.id;
};
}

BIN
topology/icons/greg-ng.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,11 @@
{ config, lib, ... }:
let
cfg = config.services.greg-ng or { enable = false; };
in
{
config.topology.self.services.greg-ng = lib.mkIf cfg.enable {
name = "Greg-ng";
icon = ../icons/greg-ng.png;
details.listen = { text = "${cfg.settings.host}:${toString cfg.settings.port}"; };
};
}