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:
parent
993cbf8acb
commit
1590461887
|
@ -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 = {
|
networking.proxy = {
|
||||||
|
|
||||||
default = lib.mkOption {
|
default = lib.mkOption {
|
||||||
|
|
|
@ -31,7 +31,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
servers = mkOption {
|
servers = mkOption {
|
||||||
default = config.services.ntp.servers;
|
default = config.networking.timeServers;
|
||||||
description = ''
|
description = ''
|
||||||
The set of NTP servers from which to synchronise.
|
The set of NTP servers from which to synchronise.
|
||||||
'';
|
'';
|
||||||
|
@ -102,7 +102,7 @@ in
|
||||||
home = stateDir;
|
home = stateDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.ntpd.enable = mkForce false;
|
systemd.services.timesyncd.enable = mkForce false;
|
||||||
|
|
||||||
systemd.services.chronyd =
|
systemd.services.chronyd =
|
||||||
{ description = "chrony NTP daemon";
|
{ description = "chrony NTP daemon";
|
||||||
|
|
|
@ -34,7 +34,7 @@ in
|
||||||
services.ntp = {
|
services.ntp = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = !config.boot.isContainer;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Whether to synchronise your machine's time using the NTP
|
Whether to synchronise your machine's time using the NTP
|
||||||
protocol.
|
protocol.
|
||||||
|
@ -42,12 +42,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
servers = mkOption {
|
servers = mkOption {
|
||||||
default = [
|
default = config.networking.timeServers;
|
||||||
"0.nixos.pool.ntp.org"
|
|
||||||
"1.nixos.pool.ntp.org"
|
|
||||||
"2.nixos.pool.ntp.org"
|
|
||||||
"3.nixos.pool.ntp.org"
|
|
||||||
];
|
|
||||||
description = ''
|
description = ''
|
||||||
The set of NTP servers from which to synchronise.
|
The set of NTP servers from which to synchronise.
|
||||||
'';
|
'';
|
||||||
|
@ -70,6 +65,7 @@ in
|
||||||
|
|
||||||
# Make tools such as ntpq available in the system path.
|
# Make tools such as ntpq available in the system path.
|
||||||
environment.systemPackages = [ pkgs.ntp ];
|
environment.systemPackages = [ pkgs.ntp ];
|
||||||
|
services.timesyncd.enable = mkForce false;
|
||||||
|
|
||||||
users.extraUsers = singleton
|
users.extraUsers = singleton
|
||||||
{ name = ntpUser;
|
{ name = ntpUser;
|
||||||
|
|
|
@ -49,7 +49,7 @@ in
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.ntp.enable = mkForce false;
|
services.timesyncd.enable = mkForce false;
|
||||||
|
|
||||||
# Add ntpctl to the environment for status checking
|
# Add ntpctl to the environment for status checking
|
||||||
environment.systemPackages = [ package ];
|
environment.systemPackages = [ package ];
|
||||||
|
|
|
@ -687,8 +687,5 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
services.resolved.enable = mkDefault true;
|
services.resolved.enable = mkDefault true;
|
||||||
services.timesyncd.enable = mkDefault config.services.ntp.enable;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,21 @@ with lib;
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
services.timesyncd.enable = mkOption {
|
services.timesyncd = {
|
||||||
default = false;
|
enable = mkOption {
|
||||||
type = types.bool;
|
default = !config.boot.isContainer;
|
||||||
description = ''
|
type = types.bool;
|
||||||
Enables the systemd NTP client daemon.
|
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 {
|
config = mkIf config.services.timesyncd.enable {
|
||||||
|
@ -30,8 +37,6 @@ with lib;
|
||||||
NTP=${concatStringsSep " " config.services.ntp.servers}
|
NTP=${concatStringsSep " " config.services.ntp.servers}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
systemd.services.ntpd.enable = false;
|
|
||||||
|
|
||||||
users.extraUsers.systemd-timesync.uid = config.ids.uids.systemd-timesync;
|
users.extraUsers.systemd-timesync.uid = config.ids.uids.systemd-timesync;
|
||||||
users.extraGroups.systemd-timesync.gid = config.ids.gids.systemd-timesync;
|
users.extraGroups.systemd-timesync.gid = config.ids.gids.systemd-timesync;
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ in
|
||||||
169.254.169.254 metadata.google.internal metadata
|
169.254.169.254 metadata.google.internal metadata
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.ntp.servers = [ "metadata.google.internal" ];
|
networking.timeServers = [ "metadata.google.internal" ];
|
||||||
|
|
||||||
networking.usePredictableInterfaceNames = false;
|
networking.usePredictableInterfaceNames = false;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ in
|
||||||
|
|
||||||
boot.kernelModules = [ "prl_tg" "prl_eth" "prl_fs" "prl_fs_freeze" "acpi_memhotplug" ];
|
boot.kernelModules = [ "prl_tg" "prl_eth" "prl_fs" "prl_fs_freeze" "acpi_memhotplug" ];
|
||||||
|
|
||||||
services.ntp.enable = false;
|
services.timesyncd.enable = false;
|
||||||
|
|
||||||
systemd.services.prltoolsd = {
|
systemd.services.prltoolsd = {
|
||||||
description = "Parallels Tools' service";
|
description = "Parallels Tools' service";
|
||||||
|
|
|
@ -478,7 +478,7 @@ in
|
||||||
boot.initrd.luks.devices = mkVMOverride {};
|
boot.initrd.luks.devices = mkVMOverride {};
|
||||||
|
|
||||||
# Don't run ntpd in the guest. It should get the correct time from KVM.
|
# 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; }
|
system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; }
|
||||||
''
|
''
|
||||||
|
|
|
@ -18,5 +18,5 @@
|
||||||
services.syslogd.tty = "hvc0";
|
services.syslogd.tty = "hvc0";
|
||||||
|
|
||||||
# Don't run ntpd, since we should get the correct time from Dom0.
|
# Don't run ntpd, since we should get the correct time from Dom0.
|
||||||
services.ntp.enable = false;
|
services.timesyncd.enable = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue