3
0
Fork 0
forked from mirrors/nixpkgs

ntp: make timesyncd the new default

- 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)
This commit is contained in:
Jörg Thalheim 2016-12-14 23:49:14 +01:00
parent 993cbf8acb
commit 1590461887
10 changed files with 36 additions and 26 deletions

View file

@ -84,6 +84,18 @@ in
'';
};
networking.timeServers = mkOption {
default = [
"0.nixos.pool.ntp.org"
"1.nixos.pool.ntp.org"
"2.nixos.pool.ntp.org"
"3.nixos.pool.ntp.org"
];
description = ''
The set of NTP servers from which to synchronise.
'';
};
networking.proxy = {
default = lib.mkOption {

View file

@ -31,7 +31,7 @@ in
};
servers = mkOption {
default = config.services.ntp.servers;
default = config.networking.timeServers;
description = ''
The set of NTP servers from which to synchronise.
'';
@ -102,7 +102,7 @@ in
home = stateDir;
};
systemd.services.ntpd.enable = mkForce false;
systemd.services.timesyncd.enable = mkForce false;
systemd.services.chronyd =
{ description = "chrony NTP daemon";

View file

@ -34,7 +34,7 @@ in
services.ntp = {
enable = mkOption {
default = !config.boot.isContainer;
default = false;
description = ''
Whether to synchronise your machine's time using the NTP
protocol.
@ -42,12 +42,7 @@ in
};
servers = mkOption {
default = [
"0.nixos.pool.ntp.org"
"1.nixos.pool.ntp.org"
"2.nixos.pool.ntp.org"
"3.nixos.pool.ntp.org"
];
default = config.networking.timeServers;
description = ''
The set of NTP servers from which to synchronise.
'';
@ -70,6 +65,7 @@ in
# Make tools such as ntpq available in the system path.
environment.systemPackages = [ pkgs.ntp ];
services.timesyncd.enable = mkForce false;
users.extraUsers = singleton
{ name = ntpUser;

View file

@ -49,7 +49,7 @@ in
###### implementation
config = mkIf cfg.enable {
services.ntp.enable = mkForce false;
services.timesyncd.enable = mkForce false;
# Add ntpctl to the environment for status checking
environment.systemPackages = [ package ];

View file

@ -687,8 +687,5 @@ in
};
services.resolved.enable = mkDefault true;
services.timesyncd.enable = mkDefault config.services.ntp.enable;
};
}

View file

@ -6,14 +6,21 @@ with lib;
options = {
services.timesyncd.enable = mkOption {
default = false;
type = types.bool;
description = ''
Enables the systemd NTP client daemon.
'';
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 {
@ -30,8 +37,6 @@ with lib;
NTP=${concatStringsSep " " config.services.ntp.servers}
'';
systemd.services.ntpd.enable = false;
users.extraUsers.systemd-timesync.uid = config.ids.uids.systemd-timesync;
users.extraGroups.systemd-timesync.gid = config.ids.gids.systemd-timesync;

View file

@ -125,7 +125,7 @@ in
169.254.169.254 metadata.google.internal metadata
'';
services.ntp.servers = [ "metadata.google.internal" ];
networking.timeServers = [ "metadata.google.internal" ];
networking.usePredictableInterfaceNames = false;

View file

@ -57,7 +57,7 @@ in
boot.kernelModules = [ "prl_tg" "prl_eth" "prl_fs" "prl_fs_freeze" "acpi_memhotplug" ];
services.ntp.enable = false;
services.timesyncd.enable = false;
systemd.services.prltoolsd = {
description = "Parallels Tools' service";

View file

@ -478,7 +478,7 @@ in
boot.initrd.luks.devices = mkVMOverride {};
# Don't run ntpd in the guest. It should get the correct time from KVM.
services.ntp.enable = false;
services.timesyncd.enable = false;
system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; }
''

View file

@ -18,5 +18,5 @@
services.syslogd.tty = "hvc0";
# Don't run ntpd, since we should get the correct time from Dom0.
services.ntp.enable = false;
services.timesyncd.enable = false;
}