@@ -11,19 +11,15 @@ let
1111 ntpUser = "ntp";
1212
1313 configFile = pkgs.writeText "ntp.conf" ''
14− # Keep the drift file in ${stateDir}/ntp.drift. However, since we
15− # chroot to ${stateDir}, we have to specify it as /ntp.drift.
16− driftfile /ntp.drift
14+ driftfile ${stateDir}/ntp.drift
1715
18− restrict default kod nomodify notrap nopeer noquery
19− restrict -6 default kod nomodify notrap nopeer noquery
2016 restrict 127.0.0.1
2117 restrict -6 ::1
2218
2319 ${toString (map (server: "server " + server + " iburst\n") config.services.ntp.servers)}
2420 '';
2521
26− ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup -i ${stateDir}";
22+ ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup";
2723
2824in
2925
@@ -64,7 +60,7 @@ in
6460
6561 config = mkIf config.services.ntp.enable {
6662
67− # Make tools such as ntpq available in the system path
63+ # Make tools such as ntpq available in the system path.
6864 environment.systemPackages = [ pkgs.ntp ];
6965
7066 users.extraUsers = singleton
@@ -74,20 +70,20 @@ in
7470 home = stateDir;
7571 };
7672
77− jobs.ntpd =
73+ systemd.services.ntpd =
7874 { description = "NTP Daemon";
7975
8076 wantedBy = [ "multi-user.target" ];
8177
82− path = [ ntp ];
83−
8478 preStart =
8579 ''
8680 mkdir -m 0755 -p ${stateDir}
8781 chown ${ntpUser} ${stateDir}
8882 '';
8983
90− exec = "ntpd -g -n ${ntpFlags}";
84+ serviceConfig = {
85+ ExecStart = "@${ntp}/bin/ntpd ntpd -g -n ${ntpFlags}";
86+ };
9187 };
9288
9389 };