diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2024-09-29 19:56:08 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2024-10-27 19:08:46 +0100 |
| commit | 491c4bf6b4596b486b12724e9124a854cc7abc26 (patch) | |
| tree | 3911453e589959da652a1d5f62e5966b05f1643e /config/networking/services/dhcp.nix | |
| parent | 072ad00164e98823691e7da1cdd07ac368391c38 (diff) | |
migrate hostapd config
Diffstat (limited to 'config/networking/services/dhcp.nix')
| -rw-r--r-- | config/networking/services/dhcp.nix | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/config/networking/services/dhcp.nix b/config/networking/services/dhcp.nix index e43d513..e513423 100644 --- a/config/networking/services/dhcp.nix +++ b/config/networking/services/dhcp.nix @@ -3,18 +3,18 @@ lib, ... }: let - nets = config.personal.networking.networks; + ifaces = config.personal.networking.interfaces; netdevServices = - builtins.map (subnet: "${subnet.interface}-netdev.service") - (with nets; [wan iot]); + builtins.map (iface: "${iface}-netdev.service") + ["wan" "iot" "guest"]; # not enp3s0 because it may come down for good reasons in { services.kea.dhcp4 = { enable = true; settings = let - subnets = with nets; [wan iot eth0]; + subnets = with ifaces; lib.filterAttrs (_: builtins.hasAttr "subnet") ifaces.all; in { interfaces-config = { - interfaces = builtins.map (network: network.interface) subnets; + interfaces = builtins.attrNames subnets; service-sockets-max-retries = 20; service-sockets-retry-wait-time = 5000; }; @@ -28,7 +28,7 @@ in { option-data = [ { name = "domain-name-servers"; - data = "${nets.lan.subnet}.1, 9.9.9.9"; + data = lib.concatStringsSep ", " config.networking.nameservers; } { name = "subnet-mask"; @@ -36,31 +36,33 @@ in { } ]; subnet4 = - builtins.map (network: { - subnet = "${network.subnet}.0/24"; + lib.mapAttrsToList (interface: { + subnet, + machines, + ... + }: { + subnet = "${subnet.prefix}.0/${builtins.toString subnet.prefixLength}"; option-data = [ { name = "broadcast-address"; - data = "${network.subnet}.255"; + data = "${subnet.prefix}.255"; } { name = "routers"; - data = network.machines.self.ip; + data = machines.self.ip; } ]; - inherit (network) interface; - pools = [{pool = "${network.subnet}.10 - ${network.subnet}.99";}]; - reservations = let - machines = builtins.attrValues (lib.filterAttrs (name: {mac, ...}: name != "self" && mac != null) network.machines); - in - builtins.map ({ + inherit interface; + pools = [{pool = "${subnet.prefix}.10 - ${subnet.prefix}.99";}]; + reservations = + lib.mapAttrsToList (_: { ip, mac, }: { hw-address = mac; ip-address = ip; }) - machines; + (lib.filterAttrs (name: addresses: name != "self" && addresses ? mac && addresses ? ip) machines); }) subnets; }; |
