c039e286b9
This allows Xen (and EC2) to power off an instance properly. We had this before (see aeb89fc753c6f95c9d143e6f5346f92e4a02fa67), but it got lost in the systemd migration.
28 lines
654 B
Nix
28 lines
654 B
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
{
|
|
|
|
# This unit saves the value of the system clock to the hardware
|
|
# clock on shutdown.
|
|
systemd.units."save-hwclock.service" =
|
|
{ wantedBy = [ "shutdown.target" ];
|
|
|
|
text =
|
|
''
|
|
[Unit]
|
|
Description=Save Hardware Clock
|
|
DefaultDependencies=no
|
|
Before=shutdown.target
|
|
|
|
[Service]
|
|
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";
|
|
|
|
}
|