1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-23 14:11:36 +00:00
nixpkgs/nixos/modules/system/boot/shutdown.nix
2020-11-24 12:42:06 -05:00

28 lines
659 B
Nix

{ config, lib, pkgs, ... }:
with lib;
{
# 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";
};
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";
}