Description
Describe the bug
Quoting the excellent NixOS manual as context:
sysinit.target
is a systemd target that encodes system initialization (i.e. early startup). A few units that need to run very early in the bootup process are ordered to finish before this target is reached. Probably the most notable one of these issystemd-tmpfiles-setup.service
. We will refer to these units as "sysinit units"."Normal" systemd units, by default, are ordered AFTER
sysinit.target
. In other words, these "normal" units expect all services ordered beforesysinit.target
to have finished without explicitly declaring this dependency relationship for each dependency. See the systemd bootup for more details on the bootup process.When restarting both a unit ordered before
sysinit.target
as well as one after, this presents a problem because they would be started at the same time as they do not explicitly declare their dependency relations.To solve this, NixOS has an artificial
sysinit-reactivation.target
which allows you to ensure that services ordered beforesysinit.target
are restarted correctly. This applies both to the ordering between these sysinit services as well as ensuring that sysinit units are restarted before "normal" units.
Currently, sysinit-reactivation.target
ignores almost all sysinit units except systemd-tmpfiles-resetup.service
(systemd-tmpfiles-setup.service
):
> systemctl list-dependencies sysinit-reactivation.target --after
sysinit-reactivation.target
● └─systemd-tmpfiles-resetup.service
This means order, implicitly added by sysinit.target
, between normal units and almost all sysinit units is ignored by nixos-rebuild switch
(or test
).
Steps To Reproduce
Issues caused by this:
nixos-rebuild switch
(ornixos-rebuild switch
) fails to start kanata when enablingservices.kanata
for the first time, a second run ofnixos-rebuild switch
succeeds #317282
nixos/kanata: test enabling kanata using nixos-rebuild switch #333955 provides a NixOS test as a minimal reproducible example.
Expected behavior
Order, implicitly added by sysinit.target, between normal units and all sysinit units is not ignored by nixos-rebuild switch
(or test
).
- For
nixos-rebuild switch
(ornixos-rebuild switch
) fails to start kanata when enablingservices.kanata
for the first time, a second run ofnixos-rebuild switch
succeeds #317282, the NixOS test added in nixos/kanata: test enabling kanata using nixos-rebuild switch #333955 passes.
Additional context
While a general fix is preferred, there are some efforts to fix this case by case:
- nixos/kanata: fix enabling kanata using
nixos-rebuild switch
#331534 adds order forsystemd-modules-load.service
andsystemd-udevd.service
Notify maintainers
@NixOS/systemd @nikstur
Add a 👍 reaction to issues you find important.