diff options
Diffstat (limited to 'nixos/modules/services/networking/ntpd.nix')
-rw-r--r-- | nixos/modules/services/networking/ntpd.nix | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/nixos/modules/services/networking/ntpd.nix b/nixos/modules/services/networking/ntpd.nix index 2f638904406..a9183577d0a 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 @@ -45,9 +41,10 @@ in servers = mkOption { default = [ - "0.pool.ntp.org" - "1.pool.ntp.org" - "2.pool.ntp.org" + "0.nixos.pool.ntp.org" + "1.nixos.pool.ntp.org" + "2.nixos.pool.ntp.org" + "3.nixos.pool.ntp.org" ]; description = '' The set of NTP servers from which to synchronise. @@ -63,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 @@ -73,13 +70,10 @@ in home = stateDir; }; - jobs.ntpd = + systemd.services.ntpd = { description = "NTP Daemon"; - wantedBy = [ "ip-up.target" ]; - partOf = [ "ip-up.target" ]; - - path = [ ntp ]; + wantedBy = [ "multi-user.target" ]; preStart = '' @@ -87,7 +81,10 @@ in chown ${ntpUser} ${stateDir} ''; - exec = "ntpd -g -n ${ntpFlags}"; + serviceConfig = { + ExecStart = "@${ntp}/bin/ntpd ntpd -g ${ntpFlags}"; + Type = "forking"; + }; }; }; |