2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.tzupdate;
|
|
|
|
in {
|
|
|
|
options.services.tzupdate = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enable the tzupdate timezone updating service. This provides
|
2020-08-20 17:08:02 +00:00
|
|
|
a one-shot service which can be activated with systemctl to
|
2020-04-24 23:36:52 +00:00
|
|
|
update the timezone.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# We need to have imperative time zone management for this to work.
|
|
|
|
# This will give users an error if they have set an explicit time
|
|
|
|
# zone, which is better than silently overriding it.
|
2020-08-20 17:08:02 +00:00
|
|
|
time.timeZone = null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# We provide a one-shot service which can be manually run. We could
|
|
|
|
# provide a service that runs on startup, but it's tricky to get
|
|
|
|
# a service to run after you have *internet* access.
|
|
|
|
systemd.services.tzupdate = {
|
|
|
|
description = "tzupdate timezone update service";
|
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
2024-10-04 16:56:33 +00:00
|
|
|
script = ''
|
|
|
|
timedatectl set-timezone $(${lib.getExe pkgs.tzupdate} --print-only)
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-04 16:56:33 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ doronbehar ];
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|