summary refs log tree commit diff
path: root/modules/system/boot/shutdown.nix
blob: ad71a2e816e3c29a1470a1a6afbc688e951a85fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ 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";

}