emilylange 2fb95a568c systemd: fix /etc/localtime symlink
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
2026-04-04 05:06:47 +02:00
2026-04-02 00:25:54 +00:00
2026-04-03 18:13:40 +00:00
2026-04-03 18:13:40 +00:00
2026-04-04 05:06:47 +02:00
2026-02-12 21:35:08 +00:00
2026-01-13 14:45:11 -05:00

NixOS logo

Contributors badge Open Collective supporters

Nixpkgs is a collection of over 120,000 software packages that can be installed with the Nix package manager. It also implements NixOS, a purely-functional Linux distribution.

Manuals

  • NixOS Manual - how to install, configure, and maintain a purely-functional Linux distribution
  • Nixpkgs Manual - contributing to Nixpkgs and using programming-language-specific Nix expressions
  • Nix Package Manager Manual - how to write Nix expressions (programs), and how to use Nix command line tools

Community

Other Project Repositories

The sources of all official Nix-related projects are in the NixOS organization on GitHub. Here are some of the main ones:

Continuous Integration and Distribution

Nixpkgs and NixOS are built and tested by our continuous integration system, Hydra.

Artifacts successfully built with Hydra are published to cache at https://cache.nixos.org/. When successful build and test criteria are met, the Nixpkgs expressions are distributed via Nix channels.

Contributing

Nixpkgs is among the most active projects on GitHub. While thousands of open issues and pull requests might seem like a lot at first, it helps to consider it in the context of the scope of the project. Nixpkgs describes how to build tens of thousands of pieces of software and implements a Linux distribution. The GitHub Insights page gives a sense of the project activity.

Community contributions are always welcome through GitHub Issues and Pull Requests.

For more information about contributing to the project, please visit the contributing page.

Donations

The infrastructure for NixOS and related projects is maintained by a nonprofit organization, the NixOS Foundation. To ensure the continuity and expansion of the NixOS infrastructure, we are looking for donations to our organization.

You can donate to the NixOS Foundation through SEPA bank transfers or by using Open Collective:

License

Nixpkgs is licensed under the MIT License.

Note

MIT license does not apply to the packages built by Nixpkgs, merely to the files in this repository (the Nix expressions, build scripts, NixOS modules, etc.). It also might not apply to patches included in Nixpkgs, which may be derivative works of the packages to which they apply. The aforementioned artifacts are all covered by the licenses of the respective packages.

S
Description
No description provided
Readme
5 GiB
Languages
Nix 95%
Shell 2%
Python 1.8%
Rust 0.3%
JavaScript 0.2%
Other 0.4%