at 23.11-pre 1.5 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.tzupdate; 7in { 8 options.services.tzupdate = { 9 enable = mkOption { 10 type = types.bool; 11 default = false; 12 description = lib.mdDoc '' 13 Enable the tzupdate timezone updating service. This provides 14 a one-shot service which can be activated with systemctl to 15 update the timezone. 16 ''; 17 }; 18 }; 19 20 config = mkIf cfg.enable { 21 # We need to have imperative time zone management for this to work. 22 # This will give users an error if they have set an explicit time 23 # zone, which is better than silently overriding it. 24 time.timeZone = null; 25 26 # We provide a one-shot service which can be manually run. We could 27 # provide a service that runs on startup, but it's tricky to get 28 # a service to run after you have *internet* access. 29 systemd.services.tzupdate = { 30 description = "tzupdate timezone update service"; 31 wants = [ "network-online.target" ]; 32 after = [ "network-online.target" ]; 33 34 serviceConfig = { 35 Type = "oneshot"; 36 # We could link directly into pkgs.tzdata, but at least timedatectl seems 37 # to expect the symlink to point directly to a file in etc. 38 # Setting the "debian timezone file" to point at /dev/null stops it doing anything. 39 ExecStart = "${pkgs.tzupdate}/bin/tzupdate -z /etc/zoneinfo -d /dev/null"; 40 }; 41 }; 42 }; 43 44 meta.maintainers = [ maintainers.michaelpj ]; 45}