git.iko.soy/typeable/nixpkgs
on master help sign in
Fix ntpd
ea9d391Eelco Dolstra
nixos/modules/services/networking/ntpd.nix+7−11
@@ -11,19 +11,15 @@ let
11 ntpUser = "ntp";
11 ntpUser = "ntp";
12
12
13 configFile = pkgs.writeText "ntp.conf" ''
13 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
17
15
18− restrict default kod nomodify notrap nopeer noquery
19− restrict -6 default kod nomodify notrap nopeer noquery
20 restrict 127.0.0.1
16 restrict 127.0.0.1
21 restrict -6 ::1
17 restrict -6 ::1
22
18
23 ${toString (map (server: "server " + server + " iburst\n") config.services.ntp.servers)}
19 ${toString (map (server: "server " + server + " iburst\n") config.services.ntp.servers)}
24 '';
20 '';
25
21
26− ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup -i ${stateDir}";
22+ ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup";
27
23
28in
24in
29
25
@@ -64,7 +60,7 @@ in
64
60
65 config = mkIf config.services.ntp.enable {
61 config = mkIf config.services.ntp.enable {
66
62
67− # Make tools such as ntpq available in the system path
63+ # Make tools such as ntpq available in the system path.
68 environment.systemPackages = [ pkgs.ntp ];
64 environment.systemPackages = [ pkgs.ntp ];
69
65
70 users.extraUsers = singleton
66 users.extraUsers = singleton
@@ -74,20 +70,20 @@ in
74 home = stateDir;
70 home = stateDir;
75 };
71 };
76
72
77− jobs.ntpd =
73+ systemd.services.ntpd =
78 { description = "NTP Daemon";
74 { description = "NTP Daemon";
79
75
80 wantedBy = [ "multi-user.target" ];
76 wantedBy = [ "multi-user.target" ];
81
77
82− path = [ ntp ];
83−
84 preStart =
78 preStart =
85 ''
79 ''
86 mkdir -m 0755 -p ${stateDir}
80 mkdir -m 0755 -p ${stateDir}
87 chown ${ntpUser} ${stateDir}
81 chown ${ntpUser} ${stateDir}
88 '';
82 '';
89
83
84+ serviceConfig = {
90− exec = "ntpd -g -n ${ntpFlags}";
85+ ExecStart = "@${ntp}/bin/ntpd ntpd -g -n ${ntpFlags}";
86+ };
91 };
87 };
92
88
93 };
89 };