summary refs log tree commit diff
path: root/nixos/modules/services/networking/dnsmasq.nix
diff options
context:
space:
mode:
authorJakob Gillich <jakob@gillich.me>2015-12-24 22:36:19 +0100
committerJakob Gillich <jakob@gillich.me>2015-12-24 22:36:19 +0100
commita193ea37008ed7295eb8d5e49f4d2341cc890b26 (patch)
tree2130fa0ffddda7d850f4f6f87ce88e5a50930ee4 /nixos/modules/services/networking/dnsmasq.nix
parentc11f6c9dc7333d6039c2e4edb1f86d12cffac520 (diff)
downloadnixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.tar
nixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.tar.gz
nixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.tar.bz2
nixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.tar.lz
nixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.tar.xz
nixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.tar.zst
nixpkgs-a193ea37008ed7295eb8d5e49f4d2341cc890b26.zip
dnsmasq: create state dir for dhcp leases file
ref #11718
Diffstat (limited to 'nixos/modules/services/networking/dnsmasq.nix')
-rw-r--r--nixos/modules/services/networking/dnsmasq.nix16
1 files changed, 10 insertions, 6 deletions
diff --git a/nixos/modules/services/networking/dnsmasq.nix b/nixos/modules/services/networking/dnsmasq.nix
index 6907d63d761..fcf5aa5f175 100644
--- a/nixos/modules/services/networking/dnsmasq.nix
+++ b/nixos/modules/services/networking/dnsmasq.nix
@@ -5,8 +5,10 @@ with lib;
 let
   cfg = config.services.dnsmasq;
   dnsmasq = pkgs.dnsmasq;
+  stateDir = "/var/lib/dnsmasq";
 
   dnsmasqConf = pkgs.writeText "dnsmasq.conf" ''
+    dhcp-leasefile=${stateDir}/dnsmasq.leases
     ${optionalString cfg.resolveLocalQueries ''
       conf-file=/etc/dnsmasq-conf.conf
       resolv-file=/etc/dnsmasq-resolv.conf
@@ -76,12 +78,11 @@ in
 
     services.dbus.packages = [ dnsmasq ];
 
-    users.extraUsers = singleton
-      { name = "dnsmasq";
-        uid = config.ids.uids.dnsmasq;
-        description = "Dnsmasq daemon user";
-        home = "/var/empty";
-      };
+    users.extraUsers = singleton {
+      name = "dnsmasq";
+      uid = config.ids.uids.dnsmasq;
+      description = "Dnsmasq daemon user";
+    };
 
     systemd.services.dnsmasq = {
         description = "Dnsmasq Daemon";
@@ -89,6 +90,9 @@ in
         wantedBy = [ "multi-user.target" ];
         path = [ dnsmasq ];
         preStart = ''
+          mkdir -m 755 -p ${stateDir}
+          touch ${stateDir}/dnsmasq.leases
+          chown -R dnsmasq ${stateDir}
           touch /etc/dnsmasq-{conf,resolv}.conf
           dnsmasq --test
         '';