summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-12-28 19:36:33 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-12-28 19:38:45 +0100
commitea9d391bb5b1f8eb26e6fc0410de353a82e4220a (patch)
tree513acca7ba646ce3eeb0f70fb25daac25eb194f2
parent782440310d69d239cc5480f97abf6a3a56a2840c (diff)
downloadnixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.tar
nixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.tar.gz
nixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.tar.bz2
nixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.tar.lz
nixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.tar.xz
nixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.tar.zst
nixlib-ea9d391bb5b1f8eb26e6fc0410de353a82e4220a.zip
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.
-rw-r--r--nixos/modules/services/networking/ntpd.nix18
1 files changed, 7 insertions, 11 deletions
diff --git a/nixos/modules/services/networking/ntpd.nix b/nixos/modules/services/networking/ntpd.nix
index 8f4bf26d411d..1988c7140d34 100644
--- a/nixos/modules/services/networking/ntpd.nix
+++ b/nixos/modules/services/networking/ntpd.nix
@@ -11,19 +11,15 @@ let
   ntpUser = "ntp";
 
   configFile = pkgs.writeText "ntp.conf" ''
-    # Keep the drift file in ${stateDir}/ntp.drift.  However, since we
-    # chroot to ${stateDir}, we have to specify it as /ntp.drift.
-    driftfile /ntp.drift
+    driftfile ${stateDir}/ntp.drift
 
-    restrict default kod nomodify notrap nopeer noquery
-    restrict -6 default kod nomodify notrap nopeer noquery
     restrict 127.0.0.1
     restrict -6 ::1
 
     ${toString (map (server: "server " + server + " iburst\n") config.services.ntp.servers)}
   '';
 
-  ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup -i ${stateDir}";
+  ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup";
 
 in
 
@@ -64,7 +60,7 @@ in
 
   config = mkIf config.services.ntp.enable {
 
-    # Make tools such as ntpq available in the system path
+    # Make tools such as ntpq available in the system path.
     environment.systemPackages = [ pkgs.ntp ];
 
     users.extraUsers = singleton
@@ -74,20 +70,20 @@ in
         home = stateDir;
       };
 
-    jobs.ntpd =
+    systemd.services.ntpd =
       { description = "NTP Daemon";
 
         wantedBy = [ "multi-user.target" ];
 
-        path = [ ntp ];
-
         preStart =
           ''
             mkdir -m 0755 -p ${stateDir}
             chown ${ntpUser} ${stateDir}
           '';
 
-        exec = "ntpd -g -n ${ntpFlags}";
+        serviceConfig = {
+          ExecStart = "@${ntp}/bin/ntpd ntpd -g -n ${ntpFlags}";
+        };
       };
 
   };