git.iko.soy/typeable/nixpkgs
on master help sign in
Fix ntpd

Since the 4.2.8 upgrade, ntpd is broken on NixOS: Dec 28 19:06:54 hagbard ntpd[27723]: giving up resolving host 1.nixos.pool.ntp.org: Servname not supported for ai_socktype (-8) This appears to be because DNS resolution doesn't work in chroots anymore (due to /etc being missing). So disable chroots for now. It's probably better to use systemd's containment facilities anyway.

commitea9d391bb5b1f8eb26e6fc0410de353a82e4220a authorEelco Dolstra <eelco.dolstra@logicblox.com> dateSun 28 Dec 2014, 19:36 (12 years ago) parent7824403
1 file changed+7−11
nixos/modules/services/networking/ntpd.nix+7−11
nixos/modules/services/networking/ntpd.nix+7−11
@@ -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 };