Skip to content

nixos/userborn: ordering cycle with var.mount at shutdown when /var is a separate filesystem #597069

Backlog

Description

@0xFelix

Nixpkgs version

  • Stable (26.11)

Describe the bug

With services.userborn.enable and /var on its own filesystem, userborn.service, var.mount, local-fs-pre.target and systemd-tmpfiles-setup-dev.service form an ordering cycle. systemd breaks it at shutdown by dropping one of the stop jobs, a different one each time (seen: userborn.service, var.mount, systemd-tmpfiles-setup-dev.service).

The links (start order):

  • userborn.service has StateDirectory=userborn, which implies RequiresMountsFor=/var/lib/userborn, so it is ordered after var.mount.
  • userborn.service is Before=systemd-tmpfiles-setup-dev.service.
  • systemd-tmpfiles-setup-dev.service is Before=local-fs-pre.target.
  • var.mount is ordered after local-fs-pre.target (default mount dependencies).

At boot there is no cycle, because /var is already mounted in the initrd (pathsNeededForBoot), so var.mount gets no start job. At shutdown all four get stop jobs.

The state directory is only used for previous-userborn.json, i.e. with users.mutableUsers = true.

Steps to reproduce

  1. A system with services.userborn.enable = true, users.mutableUsers = false, system.etc.overlay.enable = true (immutable) and /var as a separate filesystem (ZFS dataset with mountpoint=legacy here).
  2. Boot with systemd.log_target=console, then shut down.

Expected behaviour

No ordering cycle. For example, only set StateDirectory when users.mutableUsers is true (the only case that writes to it), or create the directory without the implicit mount dependency.

Screenshots

No response

Relevant log output

userborn.service: Found ordering cycle: systemd-tmpfiles-setup-dev.service/stop after local-fs-pre.target/stop after var.mount/stop after userborn.service/stop - after systemd-tmpfiles-setup-dev.service
userborn.service: Job systemd-tmpfiles-setup-dev.service/stop deleted to break ordering cycle starting with userborn.service/stop
[ SKIP ] Ordering cycle found, skipping Create Static Device Nodes in /dev

Additional context

Also seen on 26.05 ([ SKIP ] Ordering cycle found, skipping /var). No stall, the shutdown continues.

Workaround with immutable users, verified: no cycle at shutdown, and a switch still re-runs userborn. The legacy import is disabled too, since its ConditionPathExists=!/var/lib/userborn relies on the state directory:

services.userborn.importLegacyState = false;
systemd.services.userborn.serviceConfig.StateDirectory = lib.mkForce [ ];

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.18.66, NixOS, 26.11 (Zokor), 26.11.20261202.ddb397f

Notify maintainers

@nikstur

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions