This patch adds new functionality to systemd, which as per the new patch
policy is not allowed.
The main use-case this supports (imperatively installing systemd
services) is not used as far as I can tell and is not something we want
to support. Most services do not run anyways without further adjustments
on NixOS.
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
Changes:
- autovt@.service moved from a static meson-installed symlink to an
[Install] Alias= on getty@.service upstream. We do not process
[Install] sections, and logind still hardcodes spawning
autovt@ttyN.service on VT switch, so recreate the alias.
- kmscon: suppress getty@.service instead of autovt@.service.
Add static pull-in of kmsconvt@tty1 via getty.target since logind
does not spawn autovt on tty1 by design.
- modprobe@.service: upstream switched ExecStart from /sbin/modprobe to
a bare 'modprobe' relying on PATH. Update the substitution to match
the new form, since DEFAULT_PATH on NixOS is systemd's own bindir
which has no modprobe.
- Remove stale substituteInPlace patterns for paths removed upstream
(/bin/echo in test-fileio.c, /bin/cat in cat.c, /usr/bin/getent in
nspawn-setuid.c)
- Remove dead CFLAGS overrides for POLKIT_AGENT_BINARY_PATH (replaced
by runtime find_executable) and SYSTEMD_CGROUP_AGENTS_PATH (cgroup-v1
leftover, gone before v259). Use --replace-fail for the remaining
config.h substitution so future removals fail loudly.
- Remove deprecated meson options (sysvinit-path, sysvrcnd-path, libidn)
- Handle new pull-oci.c tar references
- Drop upstreamed patch 0017-meson.build-do-not-create-systemdstatedir.patch
Since systemd/systemd@c3f32b9, meson no longer probes $PATH to
locate kexec and instead hardcodes /usr/bin/kexec unless the
-Dkexec-path option is explicitly set.
kexec has probably only ever worked on NixOS because of the
fallback codepath in shutdown.c that reboots via RB_KEXEC when
the kexec binary isn't found.
Fixes#498149
woohoo! one less circular dep to worry about
from NEWS:
systemd no longer links against libcap at all. The simple system call
wrappers and other APIs it provides have been reimplemented directly
in systemd, which reduced the codebase and the dependency tree.
IDK what unl0kr is. The tests have been broken on aarch64 since the
beginning and it's not part of systemd. The maintainer of unl0kr can be
responsible for maintaining the unl0kr tests
Fixes https://github.com/NixOS/nixpkgs/pull/461277#issuecomment-3556593423
Musl does not have utmp. Systemd implicitly disables utmp support,
but we need to document this disable in nix or else `nixos/modules/system/boot/systemd.nix`
will attempt to load a non-existant service resulting in errors.
This was all originally disabled because it didn't build. Now it
does, and we can probably expect it to going forward now that musl
support has been accepted upstream.
This option is used to specify the default shell used for homed users,
among other things. By default it is set to `/bin/bash` which doesn't
exist on NixOS.
Setting this option makes `homectl create` work without having to
specify `--shell /run/current-system/sw/bin/bash`.
Without the change the eval fails as:
$ nix build --no-link -f. defaultPkgConfigPackages.libsystemd.tests
error:
… while evaluating the attribute 'systemd-timesyncd'
… in the condition of the assert statement
at pkgs/os-specific/linux/systemd/default.nix:1023:11:
1022| name: value:
1023| assert lib.assertMsg (lib.isDerivation value) "${name} is not a derivation";
| ^
1024| value
… in the left operand of the OR (||) operator
at /home/slyfox/dev/git/nixpkgs-master/lib/asserts.nix:50:31:
49| # TODO(Profpatsch): add tests that check stderr
50| assertMsg = pred: msg: pred || throw msg;
| ^
51|
error: attribute 'systemd-timesyncd' missing
at pkgs/os-specific/linux/systemd/default.nix:1010:13:
1009| systemd-sysusers-password-option-override-ordering
1010| systemd-timesyncd
| ^
1011| systemd-timesyncd-nscd-dnssec