2015-04-19 20:05:12 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2016-12-14 22:49:14 +00:00
|
|
|
services.timesyncd = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = !config.boot.isContainer;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Enables the systemd NTP client daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
servers = mkOption {
|
|
|
|
default = config.networking.timeServers;
|
|
|
|
description = ''
|
|
|
|
The set of NTP servers from which to synchronise.
|
|
|
|
'';
|
|
|
|
};
|
2015-04-19 20:05:12 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.services.timesyncd.enable {
|
|
|
|
|
2015-04-19 20:11:14 +01:00
|
|
|
systemd.additionalUpstreamSystemUnits = [ "systemd-timesyncd.service" ];
|
|
|
|
|
2015-04-19 20:05:12 +01:00
|
|
|
systemd.services.systemd-timesyncd = {
|
|
|
|
wantedBy = [ "sysinit.target" ];
|
|
|
|
restartTriggers = [ config.environment.etc."systemd/timesyncd.conf".source ];
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.etc."systemd/timesyncd.conf".text = ''
|
|
|
|
[Time]
|
|
|
|
NTP=${concatStringsSep " " config.services.ntp.servers}
|
|
|
|
'';
|
|
|
|
|
|
|
|
users.extraUsers.systemd-timesync.uid = config.ids.uids.systemd-timesync;
|
|
|
|
users.extraGroups.systemd-timesync.gid = config.ids.gids.systemd-timesync;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|