summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-06-27 02:02:48 -0500
committerWilliam A. Kennington III <william@wkennington.com>2014-08-13 15:08:43 -0500
commitb3ddcfabd9d725824f44838e86bd6e74b88c51f0 (patch)
tree5d515497a7f8e8bd3edd957f2775c3ee8ad3f29f /nixos
parent24368beed84506cf930a355b12e9b17b926dd359 (diff)
downloadnixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.tar
nixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.tar.gz
nixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.tar.bz2
nixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.tar.lz
nixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.tar.xz
nixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.tar.zst
nixlib-b3ddcfabd9d725824f44838e86bd6e74b88c51f0.zip
nixos/dhcpd: Convert to systemd from upstart
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/dhcpd.nix24
1 files changed, 17 insertions, 7 deletions
diff --git a/nixos/modules/services/networking/dhcpd.nix b/nixos/modules/services/networking/dhcpd.nix
index 2bc4e5eda43c..e1c404265f4d 100644
--- a/nixos/modules/services/networking/dhcpd.nix
+++ b/nixos/modules/services/networking/dhcpd.nix
@@ -115,22 +115,32 @@ in
       };
     };
 
-    jobs.dhcpd =
+    systemd.services.dhcpd =
       { description = "DHCP server";
 
-        startOn = "started network-interfaces";
-        stopOn = "stopping network-interfaces";
+        wantedBy = [ "multi-user.target" ];
 
-        script =
+        path = [ pkgs.dhcp ];
+
+        preStart =
           ''
             mkdir -m 755 -p ${stateDir}
 
             touch ${stateDir}/dhcpd.leases
 
-            exec ${pkgs.dhcp}/sbin/dhcpd -f --no-pid -cf ${configFile} \
-                -lf ${stateDir}/dhcpd.leases -user dhcpd -group nogroup \
-                ${toString cfg.interfaces}
+            mkdir -m 755 -p /run/dhcpd
+            chown dhcpd /run/dhcpd
           '';
+
+        serviceConfig =
+          { ExecStart = "@${pkgs.dhcp}/sbin/dhcpd dhcpd"
+              + " -pf /run/dhcpd/dhcpd.pid -cf ${configFile}"
+              + " -lf ${stateDir}/dhcpd.leases -user dhcpd -group nogroup"
+              + " ${toString cfg.interfaces}";
+            Restart = "always";
+            Type = "forking";
+            PIDFile = "/run/dhcpd/dhcpd.pid";
+          };
       };
 
   };