From 57ba31000070b462ca711527597e865b132abe03 Mon Sep 17 00:00:00 2001 From: Steffen Illium Date: Wed, 16 Jul 2025 21:41:31 +0200 Subject: [PATCH] modular interface involation --- configuration.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/configuration.nix b/configuration.nix index c14f7f0..f5b9409 100644 --- a/configuration.nix +++ b/configuration.nix @@ -24,7 +24,6 @@ ./hwaccel.nix # Services - ./keepalived.nix ./wireguard.nix ./docker.nix ./docker-device-mapper.nix @@ -47,13 +46,21 @@ networking.hostName = config.vars.hostname; # Define your hostname. networking.hostId = config.vars.hostid; # Define your hostID - Needs to be unique!. networking = { - interfaces.${lib.head config.vars.interfaces} = { - ipv4.addresses = [{ - address = config.vars.local_ip; - prefixLength = 24; - }]; - }; + interfaces = let + primaryInterface = lib.head config.vars.interfaces; + secondaryInterfaces = lib.tail config.vars.interfaces; + in + lib.foldr (name: acc: acc // { + ${name}.useDHCP = true; + }) ( + { ${primaryInterface}.ipv4.addresses = [{ + address = config.vars.local_ip; + prefixLength = 24; + }]; + } + ) secondaryInterfaces; }; + networking.defaultGateway = { address = "192.168.178.1"; interface = lib.head config.vars.interfaces;