NTP
NTP is a protocol to synchronise time and date information through a network. It is used to set the clock of your system automatically when your computer is connected to the internet.
NTP servers
To choose which servers to ask for time information to, use the networking.timeServers
option.
If you simply want to add a server to the default list, you can retrieve the default value of the option under the name options.networking.timeServers.default
. Make sure to have options
in the arguments at the beginning of the file:
/etc/nixos/configuration.nix
{ pkgs, lib, options, ...}
{
networking.timeServers = options.networking.timeServers.default ++ [ "ntp.example.com" ];
}
NTP daemon
Different NTP daemons are available on NixOS. The default one is systemd-timesyncd
. To switch to another
implementation:
- for ntpd, use
services.ntp.enable = true;
- for openntpd, use
services.openntpd.enable = true;
- for chrony, use
services.chrony.enable = true;