29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
27 lines
669 B
Nix
27 lines
669 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;
|
|
ConditionVirtualization = "!systemd-nspawn";
|
|
};
|
|
|
|
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";
|
|
|
|
}
|