dnsmasq: create state dir for dhcp leases file

ref #11718

+10 -6
+10 -6
nixos/modules/services/networking/dnsmasq.nix
··· 5 let 6 cfg = config.services.dnsmasq; 7 dnsmasq = pkgs.dnsmasq; 8 9 dnsmasqConf = pkgs.writeText "dnsmasq.conf" '' 10 ${optionalString cfg.resolveLocalQueries '' 11 conf-file=/etc/dnsmasq-conf.conf 12 resolv-file=/etc/dnsmasq-resolv.conf ··· 76 77 services.dbus.packages = [ dnsmasq ]; 78 79 - users.extraUsers = singleton 80 - { name = "dnsmasq"; 81 - uid = config.ids.uids.dnsmasq; 82 - description = "Dnsmasq daemon user"; 83 - home = "/var/empty"; 84 - }; 85 86 systemd.services.dnsmasq = { 87 description = "Dnsmasq Daemon"; ··· 89 wantedBy = [ "multi-user.target" ]; 90 path = [ dnsmasq ]; 91 preStart = '' 92 touch /etc/dnsmasq-{conf,resolv}.conf 93 dnsmasq --test 94 '';
··· 5 let 6 cfg = config.services.dnsmasq; 7 dnsmasq = pkgs.dnsmasq; 8 + stateDir = "/var/lib/dnsmasq"; 9 10 dnsmasqConf = pkgs.writeText "dnsmasq.conf" '' 11 + dhcp-leasefile=${stateDir}/dnsmasq.leases 12 ${optionalString cfg.resolveLocalQueries '' 13 conf-file=/etc/dnsmasq-conf.conf 14 resolv-file=/etc/dnsmasq-resolv.conf ··· 78 79 services.dbus.packages = [ dnsmasq ]; 80 81 + users.extraUsers = singleton { 82 + name = "dnsmasq"; 83 + uid = config.ids.uids.dnsmasq; 84 + description = "Dnsmasq daemon user"; 85 + }; 86 87 systemd.services.dnsmasq = { 88 description = "Dnsmasq Daemon"; ··· 90 wantedBy = [ "multi-user.target" ]; 91 path = [ dnsmasq ]; 92 preStart = '' 93 + mkdir -m 755 -p ${stateDir} 94 + touch ${stateDir}/dnsmasq.leases 95 + chown -R dnsmasq ${stateDir} 96 touch /etc/dnsmasq-{conf,resolv}.conf 97 dnsmasq --test 98 '';