{ pkgs, lib, config, nodes, ... }: with lib; let mkReservations = net: concatLists (mapAttrsToList (_: node: optional (hasAttr net node.config.hpc.dhcp.reservations) { "hw-address" = node.config.hpc.dhcp.reservations.${net}.hwAddress; "ip-address" = node.config.hpc.dhcp.reservations.${net}.ipAddress; }) nodes); in { services.kea = { dhcp4 = { enable = true; settings = { "valid-lifetime" = 4000; "renew-timer" = 1000; "rebind-timer" = 2000; "interfaces-config" = { "interfaces" = [ "mngt" "data" ]; }; "lease-database" = { "type" = "memfile"; "persist" = true; "name" = "/var/lib/kea/dhcp4.leases"; }; "subnet4" = [ { "subnet" = "10.32.46.0/24"; "interface" = "mngt"; "option-data" = [ { "name" = "routers"; "data" = config.networking.defaultGateway.address; } { "name" = "domain-name-servers"; "data" = "10.0.0.53,10.1.1.10"; } { "name" = "domain-name"; "data" = "mngt.${config.networking.domain}"; } { "name" = "domain-search"; "data" = "mngt.${config.networking.domain}"; } ]; "pools" = [ { "pool" = "10.32.46.100-10.32.46.200"; } ]; "reservations" = mkReservations "mngt"; } { "subnet" = "10.32.47.0/24"; "interface" = "data"; "option-data" = [ { "name" = "domain-name-servers"; "data" = "10.0.0.53,10.1.1.10"; } { "name" = "domain-name"; "data" = config.networking.domain; } { "name" = "domain-search"; "data" = config.networking.domain; } ]; "pools" = [ { "pool" = "10.32.47.100-10.32.47.200"; } ]; "reservations" = mkReservations "data"; } ]; }; }; }; }