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