From b10343c194f78a10599af367c5af3d0c0e2a77d2 Mon Sep 17 00:00:00 2001 From: kurogeek Date: Fri, 7 Aug 2026 14:50:25 +0700 Subject: [PATCH] mob next [ci-skip] [ci skip] [skip ci] lastFile:clan.nix --- clan.nix | 3 +++ modules/clan/gw-router/default.nix | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/clan.nix b/clan.nix index 46fe311..c5813b4 100644 --- a/clan.nix +++ b/clan.nix @@ -137,9 +137,12 @@ in }; }; trunkPorts = [ "enp2s0" ]; + accessPorts = { enp4s0.vlanId = 10; }; + + uplinkPorts = [ "enp3s0" ]; }; }; }; diff --git a/modules/clan/gw-router/default.nix b/modules/clan/gw-router/default.nix index 559d31b..07e1caf 100644 --- a/modules/clan/gw-router/default.nix +++ b/modules/clan/gw-router/default.nix @@ -77,7 +77,7 @@ description = "Static DHCP leases; the attribute name becomes the client's hostname."; }; }; - allowWAN = lib.mkOption { + allowedWAN = lib.mkOption { type = lib.types.bool; default = true; description = "Whether clients on this VLAN may reach the internet."; @@ -142,7 +142,10 @@ ''; }; - secondaryUpLink = lib.mkOption { }; + upLinkPorts = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "DHCP-client uplink into the existing router LAN so this machine has internet"; + }; }; }; @@ -212,6 +215,7 @@ }; }; } + // lib.optionalAttrs (settings.wan.vlanId != null) { "15-wan-lan" = { matchConfig.Name = "wan-vlan"; @@ -219,6 +223,7 @@ linkConfig.RequiredForOnline = "no"; }; } + // { "20-br0" = { matchConfig.Name = "br0"; @@ -228,6 +233,7 @@ linkConfig.RequiredForOnline = "no"; }; } + // lib.listToAttrs ( map (port: { name = "25-trunk-${port}"; @@ -239,6 +245,7 @@ }; }) settings.trunkPorts ) + // lib.mapAttrs' ( iface: port: lib.nameValuePair "25-access-${iface}" { @@ -254,6 +261,7 @@ linkConfig.RequiredForOnline = "no"; } ) settings.accessPorts + // lib.mapAttrs' ( name: vlan: lib.nameValuePair "40-${vlanIf name}" { @@ -267,7 +275,17 @@ dhcpPrefixDelegationConfig.SubnetId = "auto"; linkConfig.RequiredForOnline = "no"; } - ) settings.vlans; + ) settings.vlans + + // lib.listToAttrs ( + map (port: { + name = "5-uplink-${port}"; + value = { + matchConfig.Name = "${port}"; + networkConfig.DHCP = "ipv4"; + }; + }) settings.upLinkPorts + ); environment.systemPackages = with pkgs; [ tcpdump