at 17.09-beta 1.1 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5{ 6 7 options = { 8 9 services.timesyncd = { 10 enable = mkOption { 11 default = !config.boot.isContainer; 12 type = types.bool; 13 description = '' 14 Enables the systemd NTP client daemon. 15 ''; 16 }; 17 servers = mkOption { 18 default = config.networking.timeServers; 19 description = '' 20 The set of NTP servers from which to synchronise. 21 ''; 22 }; 23 }; 24 }; 25 26 config = mkIf config.services.timesyncd.enable { 27 28 systemd.additionalUpstreamSystemUnits = [ "systemd-timesyncd.service" ]; 29 30 systemd.services.systemd-timesyncd = { 31 wantedBy = [ "sysinit.target" ]; 32 restartTriggers = [ config.environment.etc."systemd/timesyncd.conf".source ]; 33 }; 34 35 environment.etc."systemd/timesyncd.conf".text = '' 36 [Time] 37 NTP=${concatStringsSep " " config.services.ntp.servers} 38 ''; 39 40 users.extraUsers.systemd-timesync.uid = config.ids.uids.systemd-timesync; 41 users.extraGroups.systemd-timesync.gid = config.ids.gids.systemd-timesync; 42 43 }; 44 45}