1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-22 01:11:02 +03:00
nixpkgs/nixos/modules/services/misc/tzupdate.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
Nix
Raw Normal View History

2017-10-17 09:26:02 -07:00
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.tzupdate;
in
{
options.services.tzupdate = {
enable = lib.mkOption {
type = lib.types.bool;
2017-10-17 09:26:02 -07:00
default = false;
description = ''
Enable the tzupdate timezone updating service. This provides
a one-shot service which can be activated with systemctl to
2017-10-17 09:26:02 -07:00
update the timezone.
'';
};
};
config = lib.mkIf cfg.enable {
2017-10-17 09:26:02 -07:00
# 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.
time.timeZone = null;
2017-10-17 09:26:02 -07: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" ];
script = ''
timezone="$(${lib.getExe pkgs.tzupdate} --print-only)"
if [[ -n "$timezone" ]]; then
echo "Setting timezone to '$timezone'"
timedatectl set-timezone "$timezone"
fi
'';
2017-10-17 09:26:02 -07:00
serviceConfig = {
Type = "oneshot";
};
};
};
meta.maintainers = with lib.maintainers; [ doronbehar ];
2017-10-17 09:26:02 -07:00
}