1{ config, lib, pkgs, ... }:
2
3with lib;
4
5{
6
7 # This unit saves the value of the system clock to the hardware
8 # clock on shutdown.
9 systemd.services.save-hwclock =
10 { description = "Save Hardware Clock";
11
12 wantedBy = [ "shutdown.target" ];
13
14 unitConfig = {
15 DefaultDependencies = false;
16 ConditionPathExists = "/dev/rtc";
17 };
18
19 serviceConfig = {
20 Type = "oneshot";
21 ExecStart = "${pkgs.utillinux}/sbin/hwclock --systohc ${if config.time.hardwareClockInLocalTime then "--localtime" else "--utc"}";
22 };
23 };
24
25 boot.kernel.sysctl."kernel.poweroff_cmd" = "${config.systemd.package}/sbin/poweroff";
26
27}