Skip to content

Defer image hardware setup to the Mac's first boot - #528

Merged
maralcbr merged 3 commits into
quattro-upstreamfrom
mac/41-deferred-first-session
Sep 25, 2026
Merged

maralcbr merged 3 commits into
quattro-upstreamfrom
mac/41-deferred-first-session

Conversation

@maralcbr

Copy link
Copy Markdown
Member

Ticket 41 (deferred first-session setup). Stacked on #514 (mac/13-hw-platform).

An image is built in a chroot away from the Mac it will run on, so running install/hardware/all.sh there probes the builder (and, since #514, root ignores OMARCHY_PROC_ROOT, so Apple leaves no-op in a build). This moves hardware setup of a prebuilt image to the machine's first boot, triggered by a root-owned image-target manifest instead of mx-mac's OMARCHY_MAC_IMAGE_BUILD/OMARCHY_MAC_TARGET environment.

  • The builder writes /var/lib/omarchy/image/target (format=1, platform=<omarchy-hw-platform value>, root:root, dir 0755, file 0644) before omarchy-apply-system. While it exists, omarchy-apply-hardware runs no leaf: it queues every run_logged leaf of all.sh, in order, in /var/lib/omarchy/image/deferred-steps (one install/hardware/... path per line, the mx-mac/omarchy-mac-boot format) and arms omarchy-provision-hardware.service.
  • On first boot that service (before owner setup and the display manager) runs omarchy-provision-hardware: it renames the manifest to target.booted, runs the queue with live platform detection, drops each step that succeeds, stops at a failed step (retried on the next boot), rebuilds the initramfs once if any step changed mkinitcpio inputs (baseline kept until the rebuild lands), then disarms itself. Rerunning does nothing.
  • Without a manifest nothing changes. A manifest that is not root's own regular file with a known format and platform stops hardware setup. As root every path is fixed; OMARCHY_IMAGE_ROOT is a non-root test fixture only.

Interface for the other tickets

  • 04/09 (omarchy-mac-boot first boot): in omarchy-mac-first-boot's attempt, after make_keyring, replace the hard-coded source install/hardware/apple/limine-boot.sh with /usr/bin/omarchy-provision-hardware (no arguments, root). Exit 0: nothing left. Non-zero: a step failed and stays queued; the next call resumes. Calls are serialised with the service. Also ship omarchy-provision-hardware.service.d/20-mac-first-boot.conf with After=omarchy-mac-first-boot.service, so the generic service never runs before the Mac keyring exists; it is then skipped because first boot drained the queue. Keep mac-first-boot/deferred-steps only as the initrd's fresh-image conversion token: do not switch the encrypt gate to /var/lib/omarchy/image/deferred-steps, because @factory restores that queue after a reset and would re-authorise conversion.
  • 21/23/24 (image builder): write the manifest before omarchy-apply-system and drop the OMARCHY_PROC_ROOT probe for hardware setup. Keep /var/lib/omarchy/image/ and the armed unit in @factory, so a factory-reset root reruns hardware setup on its first boot. Image inspection can require target, a non-empty deferred-steps and the enabled unit; an installed machine shows target.booted and no queue. 24 owns the detector and config side: install/config/enable-services.sh still asks the detector during the build, and the detector should read the manifest only while it is target, since first boot retires it before any step runs.

Testing

  • New test/shell.d/image-deferred-hardware-test.sh (22 checks, fixtures): the real all.sh is queued in order with no leaf run and the unit armed; no manifest runs leaves as before; bad manifests (format, platform, malformed, writable, writable dir, symlink) refuse; fixture first boot runs each leaf once, retires the manifest, rebuilds once, disarms; rerun is a no-op; failure resumes at the failed step; a failed step that changed the initramfs still gets it rebuilt; a removed leaf is skipped; unsafe queue entries refuse; a waiting hardware setup decides only under the lock; namespaced root ignores the fixture root. Mutations of the root check, queue drain, manifest retire and lock each fail it.
  • Full runtime shell suite and test/cli as a non-root user in an Arch Linux ARM container: base (Add omarchy-hw-platform and gate Apple setup on it #514 head) and branch have the same 10 environment failures (missing ffmpeg, xkbcli, omarchy-pkgs checkout and similar); the new file passes; test/cli and the omarchy-mac package tests pass.
  • Not run: a real image build and first boot. That needs the builder to write the manifest (21/23/24) and hardware or VM acceptance (25/26/28).

Second review: three rounds. It found a rebuild lost when the changing step itself failed, a manifest check before the lock, a root-unsafe test and a missing flush before disarm; all fixed, final round clean.

An image is built away from the Mac it will run on, so its hardware leaves
would probe the builder. A root-owned manifest at
/var/lib/omarchy/image/target now marks the build: hardware setup queues
every leaf instead of running it and arms omarchy-provision-hardware.service,
which runs the queue on the first boot, resumes after a failed step, rebuilds
the initramfs when a step changed it, and disarms itself. Root ignores any
environment override of these paths.
@maralcbr
maralcbr changed the base branch from mac/13-hw-platform to quattro-upstream September 25, 2026 09:44
maralcbr added a commit that referenced this pull request Sep 25, 2026
omarchy-provision-hardware does nothing without #528's build manifest, so an
image from a builder that does not write one would finish first boot with no
hardware setup and Limine never activated. A fresh image (its deferred-steps
token present) now needs /var/lib/omarchy/image/target, or target.booted once
an earlier attempt retired it; a reset root has no token and is unaffected.
@maralcbr
maralcbr merged commit 639eb28 into quattro-upstream Sep 25, 2026
5 checks passed
maralcbr added a commit that referenced this pull request Sep 25, 2026
Brings in the runtime profile and composed package lists (#542), the
platform mkinitcpio baseline (#536) and deferred first-boot setup (#528).

The Apple package list is #542's with omarchy-mac-boot after omarchy-mac.
The boot package's 90-94 drop-ins now sort after 00-omarchy-hooks.conf; a new
test composes the real baseline with them on an Apple Silicon fixture: the
encrypted systemd image gets asahi, omarchy-vendorfw, omarchy-mac-encrypt and
sd-encrypt once, a non-Latin layout stays out, and a legacy busybox encrypt
line is left as its owner set it up.
maralcbr added a commit that referenced this pull request Sep 25, 2026
omarchy-mac-boot: deterministic m1n1 device-tree order, first boot via #528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant