dnsmasq: create state dir for dhcp leases file

ref #11718

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