mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-03 19:15:39 +00:00
1590461887
- most nixos user only require time synchronisation, while ntpd implements a battery-included ntp server (1,215 LOCs of C-Code vs 64,302) - timesyncd support ntp server per interface (if configured through dhcp for instance) - timesyncd is already included in the systemd package, switching to it would save a little disk space (1,5M)
46 lines
1.1 KiB
Nix
46 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
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.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf config.services.timesyncd.enable {
|
|
|
|
systemd.additionalUpstreamSystemUnits = [ "systemd-timesyncd.service" ];
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|