2022-09-28 22:33:18 +02:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, dnsmasq
|
2023-02-25 23:53:06 +01:00
|
|
|
, serviceFns
|
2022-09-28 22:33:18 +02:00
|
|
|
, lib
|
|
|
|
}:
|
2023-08-04 21:39:29 +02:00
|
|
|
{
|
|
|
|
interface
|
|
|
|
, user
|
|
|
|
, domain
|
|
|
|
, group
|
|
|
|
, ranges
|
|
|
|
, upstreams
|
|
|
|
, resolvconf
|
|
|
|
}:
|
2022-09-28 22:33:18 +02:00
|
|
|
let
|
2023-08-04 21:39:29 +02:00
|
|
|
name = "${interface.device}.dnsmasq";
|
2022-09-28 22:33:18 +02:00
|
|
|
inherit (liminix.services) longrun;
|
|
|
|
inherit (lib) concatStringsSep;
|
2023-07-14 23:53:25 +02:00
|
|
|
in
|
|
|
|
longrun {
|
2022-09-28 22:33:18 +02:00
|
|
|
inherit name;
|
|
|
|
dependencies = [ interface ];
|
|
|
|
run = ''
|
2023-02-25 23:53:06 +01:00
|
|
|
. ${serviceFns}
|
2022-09-28 22:33:18 +02:00
|
|
|
${dnsmasq}/bin/dnsmasq \
|
|
|
|
--user=${user} \
|
|
|
|
--domain=${domain} \
|
|
|
|
--group=${group} \
|
|
|
|
--interface=${interface.device} \
|
|
|
|
${lib.concatStringsSep " " (builtins.map (r: "--dhcp-range=${r}") ranges)} \
|
|
|
|
${lib.concatStringsSep " " (builtins.map (r: "--server=${r}") upstreams)} \
|
|
|
|
--keep-in-foreground \
|
|
|
|
--dhcp-authoritative \
|
2023-02-25 23:53:50 +01:00
|
|
|
${if resolvconf != null then "--resolv-file=$(output_path ${resolvconf} resolv.conf)" else "--no-resolv"} \
|
|
|
|
--no-hosts \
|
2022-09-28 22:33:18 +02:00
|
|
|
--log-dhcp \
|
|
|
|
--enable-ra \
|
|
|
|
--log-debug \
|
2023-02-25 23:53:50 +01:00
|
|
|
--log-queries \
|
2022-09-28 22:33:18 +02:00
|
|
|
--log-facility=- \
|
|
|
|
--dhcp-leasefile=/run/${name}.leases \
|
|
|
|
--pid-file=/run/${name}.pid
|
|
|
|
'';
|
|
|
|
}
|