support dhcp static leases

This commit is contained in:
Daniel Barlow
2023-09-04 22:06:53 +01:00
parent a24c2a23a0
commit 0a6af46364
3 changed files with 133 additions and 1 deletions

View File

@@ -10,13 +10,17 @@
, domain
, group
, ranges
, hosts
, upstreams
, resolvconf
}:
let
name = "${interface.name}.dnsmasq";
inherit (liminix.services) longrun;
inherit (lib) concatStringsSep;
inherit (lib) concatStrings concatStringsSep mapAttrsToList;
hostOpt = name : { mac, v4, v6, leasetime } @ attrs:
let v6s = concatStrings (map (a : ",[${a}]") v6);
in "--dhcp-host=${mac},${v4}${v6s},${name},${builtins.toString leasetime}";
in
longrun {
inherit name;
@@ -33,6 +37,7 @@ longrun {
--keep-in-foreground \
--dhcp-authoritative \
${if resolvconf != null then "--resolv-file=$(output_path ${resolvconf} resolv.conf)" else "--no-resolv"} \
${lib.concatStringsSep " " (mapAttrsToList hostOpt hosts)} \
--no-hosts \
--log-dhcp \
--enable-ra \