diff options
author | Michael Peyton Jones <me@michaelpj.com> | 2017-10-17 09:26:02 -0700 |
---|---|---|
committer | Michael Peyton Jones <me@michaelpj.com> | 2017-10-19 05:15:32 +0100 |
commit | 281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0 (patch) | |
tree | a40dda00978e7bfbfcfb4fb5e4d5cfea7357e520 /nixos/modules/services/misc/tzupdate.nix | |
parent | 922bd8182e060e576150b0bc442f116d0a6eca1e (diff) | |
download | nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.tar nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.tar.gz nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.tar.bz2 nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.tar.lz nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.tar.xz nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.tar.zst nixlib-281bf1ddeda5705cc23ee0cf0bf95cbeb84832a0.zip |
tzupdate service: init
Diffstat (limited to 'nixos/modules/services/misc/tzupdate.nix')
-rw-r--r-- | nixos/modules/services/misc/tzupdate.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/tzupdate.nix b/nixos/modules/services/misc/tzupdate.nix new file mode 100644 index 000000000000..570982ced29a --- /dev/null +++ b/nixos/modules/services/misc/tzupdate.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.tzupdate; +in { + options.services.tzupdate = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Enable the tzupdate timezone updating service. This provides + a one-shot service which can be activated with systemctl to + 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. + time.timeZone = null; + + # 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" ]; + + serviceConfig = { + Type = "oneshot"; + # We could link directly into pkgs.tzdata, but at least timedatectl seems + # to expect the symlink to point directly to a file in etc. + # Setting the "debian timezone file" to point at /dev/null stops it doing anything. + ExecStart = "${pkgs.tzupdate}/bin/tzupdate -z /etc/zoneinfo -d /dev/null"; + }; + }; + }; + + meta.maintainers = [ maintainers.michaelpj ]; +} |