How date and time works on NixOS?

Hi, i’m a new user i’m still learning NixOS and i’d like to understand how the time and date is working with nixos ? Because i realize that NixOS is using my hardware clock to get the actual date and time but i would like it use chrony to sync the date and time instead of using the hardware clock. How to do that ?..

I thought time.timeZone = lib.mkDefault "Europe/London"; will set the date and time but it’s just useless because my system still using the hardware clock what i’m missing please ?

This is how i configured chrony in my system :

{ config, lib, … }: {

services.chrony = {
enable = true;
enableNTS = true;
extraFlags = [ “-q” ];
servers = [ “time.cloudflare.com” ];
};
}

Note : the “q” option is used here to tell chrony to sync the date and time then exit the daemon

And a another thing i realize is when my computer shutdown by itself because there is no battery and then i boot the system the clock is wrong from years…

I would be so happy if anyone help me

Does this help? NTP - NixOS Wiki

I haven’t followed what’s on that page.

If there’s no working CMOS battery then that’s expected, that’s how computers work.

Isn’t London GMT (UTC+0)? Then the hardware and local time should be the same?

1 Like

Not during DST (or BST as they call it).

1 Like

Not at all but i wonder if i have to set in my config { pkgs, lib, options, ...} { networking.timeServers = options.networking.timeServers.default ++ [ "ntp.example.com" ]; }

to make chrony work correctly.

But according to the new nixos wiki Chrony - NixOS Wiki If you don't set a serverlist here, the value of networking.timeServers will be used.

So if i understand correctly it’s totally useless to add networking.timeservers because Chrony should handle everything by itself (maybe i’m wrong i don’t know…)

Oh okay thanks you for this information :slight_smile:

Update : I tried to use ntpd-rs with the option networking.timeServers and services.ntpd-rs.useNetworkingTimeServers instead of using chrony and it’s the same result. The system do not sync the date and time via the network it’s still using the hardware clock to get the current date and time…