This should help to catch the regression described in 2fb95a568c
if it ever does end up resurfacing.
Please see that commit for more details on this.
The tl;dr is: At the very least systemd and icu::TimeZone both make
assumptions about how the /etc/localtime symlink they read should look
like. In one of our systemd patches, we broke this for both itself and
icu::TimeZone. And while we could extend our systemd patch, we cannot as
easily patch icu and we don't know who else makes similar assumptions.
This is essentially a revert of e8a805af10
in favor of a proper fix because unlike first assumed, this affects
not just systemd internally, but virtually any program that uses
icu::TimeZone to read the system's time zone.
And while we could patch icu, I believe this will take far too long and
we arguably don't know who else depends on the same assumption icu made.
All I know is every chromium-based browser[^0], including electron,
calls icu::TimeZone::detectHostTimeZone(), which returns the special
time zone Etc/Unknown instead of the configured one when using
timedated, either directly via timedatectl set-timezone or via D-Bus.
The reason for this is icu::TimeZone assumes[^1] every valid
/etc/localtime symlink includes /zoneinfo/ before the zoneinfo (olson)
timezone id.
This is a pretty decent guess and also applied to NixOS since ever, up
until we bumped systemd to v258 in 1c5d47dd78,
which included an upstream change that made the symlink relative.
The issue is, a relative /etc/localtime symlink in other distros results
in e.g. ../usr/share/zoneinfo/UTC, not zoneinfo/UTC. For NixOS, however,
we patch systemd to use /etc/zoneinfo instead of /usr/share/zoneinfo.
zoneinfo/UTC breaks the assumption icu::TimeZone makes, because
zoneinfo/ is not /zoneinfo/. We could try to trick it by needlessly
making the relative symlink ./zoneinfo/ instead, but this is both more
fragile and makes the patch significantly larger. And as stated above
already, we simply don't know who else makes similar assumptions.
So to fix this for good, we force the symlink to be absolute, just like
we had it prior to systemd v258.
Note that we could also simply unconditionally set
~~~nix
{
systemd.services."systemd-timedated".environment.SYSTEMD_ETC_LOCALTIME = "/etc/localtime";
}
~~~
to make the symlink absolute. But I'd argue this would cause this
edge-case to slowly slide into obscurity, almost asking for it to
resurface in the future eventually.
[0]: https://source.chromium.org/chromium/chromium/src/+/refs/tags/146.0.7680.177:services/device/time_zone_monitor/time_zone_monitor.cc;l=57-59;bpv=0
[1]: https://github.com/unicode-org/icu/blob/release-78.3/icu4c/source/common/putil.cpp#L686-L695