summary refs log tree commit diff
path: root/nixos/modules/system/boot/timesyncd.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@higgsboson.tk>2016-12-14 23:49:14 +0100
committerJörg Thalheim <joerg@higgsboson.tk>2016-12-17 00:00:45 +0100
commit1590461887333e2fda46f4bd74aef3785b253089 (patch)
treecd5d6652a758dc54bffd73e9d313ba5d1d73abf1 /nixos/modules/system/boot/timesyncd.nix
parent993cbf8acb9da679bb8bca00eacada6d83ed6994 (diff)
downloadnixpkgs-1590461887333e2fda46f4bd74aef3785b253089.tar
nixpkgs-1590461887333e2fda46f4bd74aef3785b253089.tar.gz
nixpkgs-1590461887333e2fda46f4bd74aef3785b253089.tar.bz2
nixpkgs-1590461887333e2fda46f4bd74aef3785b253089.tar.lz
nixpkgs-1590461887333e2fda46f4bd74aef3785b253089.tar.xz
nixpkgs-1590461887333e2fda46f4bd74aef3785b253089.tar.zst
nixpkgs-1590461887333e2fda46f4bd74aef3785b253089.zip
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)
Diffstat (limited to 'nixos/modules/system/boot/timesyncd.nix')
-rw-r--r--nixos/modules/system/boot/timesyncd.nix23
1 files changed, 14 insertions, 9 deletions
diff --git a/nixos/modules/system/boot/timesyncd.nix b/nixos/modules/system/boot/timesyncd.nix
index cba965b1cd2..f643723ab14 100644
--- a/nixos/modules/system/boot/timesyncd.nix
+++ b/nixos/modules/system/boot/timesyncd.nix
@@ -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;