diff --git a/nixos/modules/system/boot/timesyncd.nix b/nixos/modules/system/boot/timesyncd.nix index b75a413fa58ef..d54ed687c8e7b 100644 --- a/nixos/modules/system/boot/timesyncd.nix +++ b/nixos/modules/system/boot/timesyncd.nix @@ -21,12 +21,15 @@ in servers = mkOption { default = config.networking.timeServers; defaultText = literalExpression "config.networking.timeServers"; - type = listOf str; + type = nullOr (listOf str); description = '' The set of NTP servers from which to synchronise. - Note if this is set to an empty list, the defaults systemd itself is - compiled with ({0..4}.nixos.pool.ntp.org) apply, - In case you want to disable timesyncd altogether, use the `enable` option. + + Setting this option to an empty list will write `NTP=` to the + `timesyncd.conf` file as opposed to setting this option to null which + will remove `NTP=` entirely. + + See man:timesyncd.conf(5) for details. ''; }; extraConfig = mkOption { @@ -85,9 +88,11 @@ in environment.etc."systemd/timesyncd.conf".text = '' [Time] + '' + + optionalString (cfg.servers != null) '' NTP=${concatStringsSep " " cfg.servers} - ${cfg.extraConfig} - ''; + '' + + cfg.extraConfig; users.users.systemd-timesync = { uid = config.ids.uids.systemd-timesync;