Unverified Commit 255a11d6 authored by zowoq's avatar zowoq Committed by GitHub
Browse files

shutdown: stop manually saving hwclock (#494162)

parents a542077c 2b724de1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -96,6 +96,15 @@ in
    // lib.optionalAttrs (config.time.timeZone != null) {
      localtime.source = "/etc/zoneinfo/${config.time.timeZone}";
      localtime.mode = "direct-symlink";
    }
    // lib.optionalAttrs config.time.hardwareClockInLocalTime {
      # Mirrors timedated
      # https://github.com/systemd/systemd/blob/afaca649ad678031a46182b0cce667cbbbf47a6d/src/timedate/timedated.c#L325-L396
      adjtime.text = ''
        0.0 0 0
        0
        LOCAL
      '';
    };
  };

+0 −5
Original line number Diff line number Diff line
@@ -264,11 +264,6 @@ in

    services.timesyncd.enable = lib.mkForce false;

    # If chrony controls and tracks the RTC, writing it externally causes clock error.
    systemd.services.save-hwclock = lib.mkIf cfg.enableRTCTrimming {
      enable = lib.mkForce false;
    };

    systemd.services.systemd-timedated.environment = {
      SYSTEMD_TIMEDATED_NTP_SERVICES = "chronyd.service";
    };
+0 −23
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:

{

  # This unit saves the value of the system clock to the hardware
  # clock on shutdown.
  systemd.services.save-hwclock = {
    description = "Save Hardware Clock";

    wantedBy = [ "shutdown.target" ];

    unitConfig = {
      DefaultDependencies = false;
      ConditionPathExists = "/dev/rtc";
      ConditionPathIsReadWrite = "/etc/";
    };

    serviceConfig = {
      Type = "oneshot";
      ExecStart = "${pkgs.util-linux}/sbin/hwclock --systohc ${
        if config.time.hardwareClockInLocalTime then "--localtime" else "--utc"
      }";
    };
  };

  boot.kernel.sysctl."kernel.poweroff_cmd" = "${config.systemd.package}/sbin/poweroff";

}