mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 08:01:14 +00:00
5bfe944907
E.g. on EC2 instances. Backport: 14.04
28 lines
658 B
Nix
28 lines
658 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.utillinux}/sbin/hwclock --systohc ${if config.time.hardwareClockInLocalTime then "--localtime" else "--utc"}";
|
|
};
|
|
};
|
|
|
|
boot.kernel.sysctl."kernel.poweroff_cmd" = "${config.systemd.package}/sbin/poweroff";
|
|
|
|
}
|