mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 17:54:53 +01:00
34 lines
694 B
Nix
34 lines
694 B
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
{
|
|
|
|
# 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";
|
|
ConditionPathIsReadWrite = "/etc/";
|
|
};
|
|
|
|
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";
|
|
|
|
}
|