liminix/pkgs/liminix-tools/networking/dnsmasq.nix
Daniel Barlow c320d0afc7 add dnsmasq and example config for it
would be good to move more of this into a module, but that
doesn't sit well with the (potential) ability to run more than one
dnsmasq service, as modules are singletons
2022-09-28 21:33:18 +01:00

39 lines
839 B
Nix

{
liminix
, dnsmasq
, lib
}:
{
user ? "dnsmasq"
, group ? "dnsmasq"
, interface
, upstreams ? []
, ranges
, domain
} :
let
inherit (liminix.services) longrun;
inherit (lib) concatStringsSep;
name = "${interface.device}.dnsmasq";
in longrun {
inherit name;
dependencies = [ interface ];
run = ''
${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 \
--no-resolv \
--log-dhcp \
--enable-ra \
--log-debug \
--log-facility=- \
--dhcp-leasefile=/run/${name}.leases \
--pid-file=/run/${name}.pid
'';
}