Commit 32866ce

HPCesia <me@hpcesia.com>
2025-10-23 20:37:07
feat: laptop time sync
1 parent 4839b39
Changed files (3)
modules/core/networking/timeserver.nix
@@ -1,9 +0,0 @@
-{
-  flake.modules.nixos.core = _: {
-    # Use an NTP server located in the mainland of China to synchronize the system time
-    networking.timeServers = [
-      "ntp.aliyun.com" # Aliyun NTP Server
-      "ntp.tencent.com" # Tencent NTP Server
-    ];
-  };
-}
modules/core/networking/nameserver.nix → modules/core/nameserver.nix
File renamed without changes
modules/core/time-sync.nix
@@ -0,0 +1,17 @@
+{lib, ...} @ topArgs: {
+  flake.modules.nixos.core = {config, ...}: let
+    hostMeta = topArgs.config.flake.meta.host.hosts.${config.networking.hostName};
+  in {
+    # Use an NTP server located in the mainland of China to synchronize the system time
+    networking.timeServers = [
+      "ntp.aliyun.com" # Aliyun NTP Server
+      "ntp.tencent.com" # Tencent NTP Server
+    ];
+
+    # Use chrony for better time synchronization on laptops
+    services.timesyncd.enable = lib.mkIf (hostMeta.isLaptop) false;
+    services.chrony = lib.mkIf (hostMeta.isLaptop) {
+      enable = true;
+    };
+  };
+}