1{ config, lib, pkgs, ... }: 2 3with lib; 4 5{ 6 7 options = { 8 9 services.timesyncd.enable = mkOption { 10 default = false; 11 type = types.bool; 12 description = '' 13 Enables the systemd NTP client daemon. 14 ''; 15 }; 16 17 }; 18 19 config = mkIf config.services.timesyncd.enable { 20 21 systemd.additionalUpstreamSystemUnits = [ "systemd-timesyncd.service" ]; 22 23 systemd.services.systemd-timesyncd = { 24 wantedBy = [ "sysinit.target" ]; 25 restartTriggers = [ config.environment.etc."systemd/timesyncd.conf".source ]; 26 }; 27 28 environment.etc."systemd/timesyncd.conf".text = '' 29 [Time] 30 NTP=${concatStringsSep " " config.services.ntp.servers} 31 ''; 32 33 systemd.services.ntpd.enable = false; 34 35 users.extraUsers.systemd-timesync.uid = config.ids.uids.systemd-timesync; 36 users.extraGroups.systemd-timesync.gid = config.ids.gids.systemd-timesync; 37 38 }; 39 40}