mob next [ci-skip] [ci skip] [skip ci]

lastFile:clan.nix
This commit is contained in:
2026-08-10 16:55:43 +07:00
parent 049270c2ca
commit fdf53873cb
3 changed files with 49 additions and 101 deletions
+47 -99
View File
@@ -1,4 +1,9 @@
{ inputs, self, ... }: {
inputs,
self,
libNet,
...
}:
let let
hosts = import ./modules/hosts.nix; hosts = import ./modules/hosts.nix;
@@ -60,111 +65,54 @@ in
name = "gw-router"; name = "gw-router";
input = "self"; input = "self";
}; };
roles.default.machines."gw-cnx-1" = { roles.default.machines."gw-cnx-1" =
settings = { let
wan = { genVlan = id: length: rec {
interface = "enp1s0"; inherit id;
vlanId = null; prefixLength = length;
subnet = libNet.net.cidr.make length "10.0.${id}.0";
address = libNet.net.cidr.host 1 subnet;
dhcp.pool.from = libNet.net.cidr.host 100 subnet;
dhcp.pool.to = libNet.net.cidr.host 200 subnet;
}; };
vlans = { in
mgmt = { {
id = 10; settings = {
address = "10.1.10.1"; wan = {
prefixLength = 24; interface = "enp1s0";
subnet = "10.1.10.0/24"; vlanId = null;
dhcp.fixedIPs.storinator01 = { };
hwAddress = "7c:c2:55:e0:d6:40"; vlans = {
ipAddress = "10.1.10.53"; mgmt = genVlan 10 24 // {
dhcp.fixedIPs.storinator01 = {
hwAddress = "7c:c2:55:e0:d6:40";
ipAddress = "10.1.10.53";
};
}; };
dhcp.pool.from = "10.1.10.100"; lan = genVlan 20 24;
dhcp.pool.to = "10.1.10.200"; iot = genVlan 40 24;
}; voip = genVlan 50 24;
lan = { dmz = genVlan 60 24;
id = 20; unit1 = genVlan 110 24;
address = "10.1.20.1"; unit2 = genVlan 120 24;
prefixLength = 24; unit3 = genVlan 130 24;
subnet = "10.1.20.0/24"; unit4 = genVlan 140 24;
dhcp.pool.from = "10.1.20.100"; unit5 = genVlan 150 24 // {
dhcp.pool.to = "10.1.20.200"; dhcp.fixedIPs.newt = {
}; hwAddress = "7c:d3:0a:21:58:0b";
iot = { ipAddress = "10.1.150.22";
id = 40; };
address = "10.1.40.1";
prefixLength = 24;
subnet = "10.1.40.0/24";
dhcp.pool.from = "10.1.40.100";
dhcp.pool.to = "10.1.40.200";
};
voip = {
id = 50;
address = "10.1.50.1";
prefixLength = 24;
subnet = "10.1.50.0/24";
dhcp.pool.from = "10.1.50.100";
dhcp.pool.to = "10.1.50.200";
};
dmz = {
id = 60;
address = "10.1.60.1";
prefixLength = 24;
subnet = "10.1.60.0/24";
dhcp.pool.from = "10.1.60.100";
dhcp.pool.to = "10.1.60.200";
};
unit1 = {
id = 110;
address = "10.1.110.1";
prefixLength = 24;
subnet = "10.1.110.0/24";
dhcp.pool.from = "10.1.110.100";
dhcp.pool.to = "10.1.110.200";
};
unit2 = {
id = 120;
address = "10.1.120.1";
prefixLength = 24;
subnet = "10.1.120.0/24";
dhcp.pool.from = "10.1.120.100";
dhcp.pool.to = "10.1.120.200";
};
unit3 = {
id = 130;
address = "10.1.130.1";
prefixLength = 24;
subnet = "10.1.130.0/24";
dhcp.pool.from = "10.1.130.100";
dhcp.pool.to = "10.1.130.200";
};
unit4 = {
id = 140;
address = "10.1.140.1";
prefixLength = 24;
subnet = "10.1.140.0/24";
dhcp.pool.from = "10.1.140.100";
dhcp.pool.to = "10.1.140.200";
};
unit5 = {
id = 150;
address = "10.1.150.1";
prefixLength = 24;
subnet = "10.1.150.0/24";
dhcp.fixedIPs.newt = {
hwAddress = "7c:d3:0a:21:58:0b";
ipAddress = "10.1.150.22";
}; };
dhcp.pool.from = "10.1.150.100";
dhcp.pool.to = "10.1.150.200";
}; };
}; trunkPorts = [ "enp2s0" ];
trunkPorts = [ "enp2s0" ];
accessPorts = { accessPorts = {
enp4s0.vlanId = 10; enp4s0.vlanId = 10;
}; };
upLinkPorts = [ "enp3s0" ]; upLinkPorts = [ "enp3s0" ];
};
}; };
};
}; };
root-user = { root-user = {
+2
View File
@@ -34,6 +34,8 @@
./modules/clan/flake-module.nix ./modules/clan/flake-module.nix
]; ];
_module.args.libNet = inputs.nixpkgs.lib.extend inputs.nix-lib-net.overlays.raw;
perSystem = perSystem =
{ system, ... }: { system, ... }:
let let
-2
View File
@@ -4,11 +4,9 @@
{ {
lib, lib,
inputs,
... ...
}: }:
let let
libNet = lib.extend inputs.nix-lib-net.overlays.default;
dhcpVlans = lib.filterAttrs (_: vlan: vlan.dhcp.enable) settings.vlans; dhcpVlans = lib.filterAttrs (_: vlan: vlan.dhcp.enable) settings.vlans;
in in
{ {