Change:
Describe the bug The field of systemd timer units is treated as UTC, even if a different timezone is specified. To Reproduce a trivial service and make it start at midnight on some non-UTC timezone: and observe that the field says midnight UTC (in my case, ). Expected behavior In this case, the field should say (or ). Additional context I have tested this with two different non-UTC timezones. on the same machine gives the correct result, so this is linked to timer units. I am using the systemd package from the NixOS 20.09 release, version 246. I could not reproduce the issue on an Arch Linux server (systemd 246.4-1-arch), so it's (probably) a NixOS problem. Notify maintainers Metadata
Maybe our patch in (from ) isn't sufficient and this needs to be patched in another location, too?
Note that if I specify a timezone that doesn't exist, I get an error on activation. So presumably it can find the timezone info, it just doesn't respect it.
Can you reproduce on non-NixOS?
Nope, see the fourth bullet point under Additional context.
I was able to reproduce this on NixOS, and verified it works correctly on Archlinux. I still don't understand why it behaves the way it does (it seems we did properly patch all occurences this might touch). This might require some deeper digging into the codebase, and adding some logs along the way to see what's going on.
I marked this as stale due to inactivity. &rarr;
Not stale, but help welcome ;-)
I haven't had time to test this but a cursory reading of the systemd code shows that it uses : tzset uses TZDIR. On a normal nixos system I get this: but pid 1 doesn't set TZDIR:
I confirmed TZDIR is the issue by applying the following patch. I think my fix is wrong but I couldn't figure out where in systemd pid 1 I should set env vars so I did id in a function that I know will be called. without patch: with patch: unit used:
I wonder if this is related to and
Yeah, this looks about right. Maybe we should see if we can steer glibc to look for zoneinfo in these two paths by default, instead of in the glibc output directly.

Discussion:
PATH=/run/current-system/systemd/lib/systemd:@fsPackagesPath@  LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive @systemdUnitPathEnvVar@  <ins> TZDIR=/etc/zoneinfo  </ins> exec @systemdExecutable@

umount /tmp/shared ''; <ins> systemd.services.oncalendar-test = { description = "calendar test"; # Japan does not have DST which makes the test a little bit simpler startAt = "Wed 10:00 Asia/Tokyo"; script = "true"; }; </ins> systemd.services.testservice1 = { description = "Test Service 1"; wantedBy = [ "multi-user.target" ];

# wait for user services machine.wait_for_unit("default.target", "alice") <ins> # Regression test for https://github.com/NixOS/nixpkgs/issues/105049 with subtest("systemd reads timezone database in /etc/zoneinfo"): timer = machine.succeed("TZ=UTC systemctl show --property=TimersCalendar oncalendar-test.timer") assert re.search("next_elapse=Wed ....-..-.. 01:00:00 UTC", timer), f"got {timer.strip()}" </ins> # Regression test for https://github.com/NixOS/nixpkgs/issues/35415 with subtest("configuration files are recognized by systemd"): machine.succeed("test -e /system_conf_read")