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.
This commit is contained in:
Eelco Dolstra 2014-12-28 19:36:33 +01:00 committed by Peter Simons
parent 056ace5bca
commit 47971865e9
1 changed files with 7 additions and 11 deletions

View File

@ -11,19 +11,15 @@ let
ntpUser = "ntp"; ntpUser = "ntp";
configFile = pkgs.writeText "ntp.conf" '' configFile = pkgs.writeText "ntp.conf" ''
# Keep the drift file in ${stateDir}/ntp.drift. However, since we driftfile ${stateDir}/ntp.drift
# chroot to ${stateDir}, we have to specify it as /ntp.drift.
driftfile /ntp.drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 restrict 127.0.0.1
restrict -6 ::1 restrict -6 ::1
${toString (map (server: "server " + server + " iburst\n") config.services.ntp.servers)} ${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 in
@ -64,7 +60,7 @@ in
config = mkIf config.services.ntp.enable { 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 ]; environment.systemPackages = [ pkgs.ntp ];
users.extraUsers = singleton users.extraUsers = singleton
@ -74,20 +70,20 @@ in
home = stateDir; home = stateDir;
}; };
jobs.ntpd = systemd.services.ntpd =
{ description = "NTP Daemon"; { description = "NTP Daemon";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
path = [ ntp ];
preStart = preStart =
'' ''
mkdir -m 0755 -p ${stateDir} mkdir -m 0755 -p ${stateDir}
chown ${ntpUser} ${stateDir} chown ${ntpUser} ${stateDir}
''; '';
exec = "ntpd -g -n ${ntpFlags}"; serviceConfig = {
ExecStart = "@${ntp}/bin/ntpd ntpd -g -n ${ntpFlags}";
};
}; };
}; };