0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

nixos/timesyncd: allow NTP servers advertised by DHCP to be used

- add option `fallbackServers` with default to `networking.timeServers`
- option `servers` now default to null

Fix #335050
This commit is contained in:
datafoo 2024-08-16 10:56:01 +02:00
parent b4cd57870d
commit 24e08d0e9b
2 changed files with 22 additions and 2 deletions

View file

@ -19,8 +19,7 @@ in
'';
};
servers = mkOption {
default = config.networking.timeServers;
defaultText = literalExpression "config.networking.timeServers";
default = null;
type = nullOr (listOf str);
description = ''
The set of NTP servers from which to synchronise.
@ -32,6 +31,20 @@ in
See man:timesyncd.conf(5) for details.
'';
};
fallbackServers = mkOption {
default = config.networking.timeServers;
defaultText = literalExpression "config.networking.timeServers";
type = nullOr (listOf str);
description = ''
The set of fallback NTP servers from which to synchronise.
Setting this option to an empty list will write `FallbackNTP=` to the
`timesyncd.conf` file as opposed to setting this option to null which
will remove `FallbackNTP=` entirely.
See man:timesyncd.conf(5) for details.
'';
};
extraConfig = mkOption {
default = "";
type = lines;
@ -92,6 +105,9 @@ in
+ optionalString (cfg.servers != null) ''
NTP=${concatStringsSep " " cfg.servers}
''
+ optionalString (cfg.fallbackServers != null) ''
FallbackNTP=${concatStringsSep " " cfg.fallbackServers}
''
+ cfg.extraConfig;
users.users.systemd-timesync = {