From 9bd20c90a7c150e1909872dfd8e5922902c1d6dc Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 12 Jan 2025 14:28:33 +0200 Subject: [PATCH 1/2] tzupdate: be resilient to network issues tzupdate experiences --- nixos/modules/services/misc/tzupdate.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/misc/tzupdate.nix b/nixos/modules/services/misc/tzupdate.nix index 188ef95e185d..d100e620337b 100644 --- a/nixos/modules/services/misc/tzupdate.nix +++ b/nixos/modules/services/misc/tzupdate.nix @@ -28,6 +28,7 @@ in { wants = [ "network-online.target" ]; after = [ "network-online.target" ]; script = '' + set -uo pipefail timedatectl set-timezone "$(${lib.getExe pkgs.tzupdate} --print-only)" ''; From f74883a69121015d6a5106fa9057a83b647be7df Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Fri, 17 Jan 2025 10:36:40 +0200 Subject: [PATCH 2/2] nixos/tzupdate: report timezone being set in journal Also, no need for set -uo pipefail as there are no pipes there at the moment. --- nixos/modules/services/misc/tzupdate.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/misc/tzupdate.nix b/nixos/modules/services/misc/tzupdate.nix index d100e620337b..85b1b3647ef7 100644 --- a/nixos/modules/services/misc/tzupdate.nix +++ b/nixos/modules/services/misc/tzupdate.nix @@ -28,8 +28,11 @@ in { wants = [ "network-online.target" ]; after = [ "network-online.target" ]; script = '' - set -uo pipefail - timedatectl set-timezone "$(${lib.getExe pkgs.tzupdate} --print-only)" + timezone="$(${lib.getExe pkgs.tzupdate} --print-only)" + if [[ -n "$timezone" ]]; then + echo "Setting timezone to '$timezone'" + timedatectl set-timezone "$timezone" + fi ''; serviceConfig = {