Repository navigation
Take an image build's platform from its manifest, and ignore root's environment - #546
Merged
Merged
Conversation
…ironment out of the detector While a root is being built rather than booted, omarchy-hw-platform prints the platform the root-owned image-target manifest names instead of reading the build host's device tree, so an Apple image built on any host gets the Apple initramfs, services and packages. A booted system, one systemd runs from PID 1's root, always answers from its hardware, even with a stale manifest. The detector and the Apple predicates run in bash's privileged mode, and root restarts the detector in an empty environment, so exported functions, BASH_ENV, PATH and fixture roots cannot pick the platform for a privileged caller.
…hat cannot be seen A PID namespace build with the host's /run bound in showed systemd's runtime directory and PID 1 in the root, so it passed for a booted system. PID 1 must also be systemd. What a caller cannot see, PID 1's root or PID 1 behind hidepid, no longer makes a build, so a booted system always answers from its hardware. The probes pick a target the live hardware would not give, so they also hold on a Mac.
…rivate PID namespaces bash run on a script found through PATH sets $0 to the bare name, which the restarted shell's fixed PATH may not find; BASH_SOURCE holds the path. A caller in a private PID namespace looks like a build, so the docs say so and a test keeps PrivatePIDs= out of the units. The live probe skips on a noexec temporary directory.
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket 24. An Apple image built on a non-Apple host got
generic-aarch64fromomarchy-hw-platform, because as root it reads only the live device tree. The Apple initramfs, services and packages then went missing, and the platform guard (#539) would refuse the Apple packages.What changed
The manifest names an image's platform. While a root is being built,
omarchy-hw-platformprints the platform in the root-owned image-target manifest from Defer image hardware setup to the Mac's first boot #528 (/var/lib/omarchy/image/target). It never reads the build host's device tree.How a build is told from a booted system. A root counts as booted only when systemd runs it as PID 1. The detector treats it as a build when any of these is visible:
/run/systemd/system(arch-chroot, pacstrap and the image builder each give the root its own/run);/runbound in).Anything the caller cannot see counts as booted: PID 1's root for a normal user, or PID 1 hidden by
hidepid. So a booted Mac, Snapdragon, VM or x86 machine always answers from its hardware, even when a stale or broken manifest is left behind.A bad manifest stops a build instead of guessing. Each of these fails the detector, which stops mkinitcpio and the guard:
The manifest is parsed by the same rules as
install/helpers/image-target.sh. The detector reads it itself, so a copy of the detector shipped in another package still works.Root's environment cannot change the answer. The detector and both Apple predicates now run as
bash -p. As root, the detector restarts underenv -iwith a fixed PATH, the same way Lifecycle dispatch interface, wired into owner provisioning #540's dispatcher and Add the package platform tag and a pacman platform guard #539's guard do. Exported functions,BASH_ENV, PATH and the fixture roots therefore have no effect on what root gets. This closes the exported-function hole found in ticket 17. The predicates also stop looking anything up in PATH.First boot asks the hardware after retiring the manifest.
omarchy-provision-hardwarenow calls the detector only after it has retired the manifest, so its log line always shows the real hardware.Callers need no change.
00-omarchy-hooks.conf, thesystemd-oomdstep inenable-services.sh,omarchy-pkg-defaults, the Build the Apple initramfs drop-ins on the HOOKS baseline, Apple only #544 drop-ins and the Add the package platform tag and a pacman platform guard #539 guard all go through the detector.For the stacked work
omarchy-hw-platformno longer relies on the builder's fake/sys/firmwaredevice tree. Other probes still read that tree. The builder must write the manifest before the first transaction that runs mkinitcpio or the guard, and must give the root its own/run. The oldOMARCHY_PROC_ROOTprobe inconfigured_phases.pyon the installer'smainbranch does nothing for root and can be removed.Tests
test/shell.d/image-target-platform-test.sh, with fixtures for:/run;/proc;hidepid;BASH_ENVand exporteduname,mapfile,statanddirnamefunctions, with and without--clean-environment;image-deferred-hardware-test.shgains a case where an image boots on other hardware.hermes-remove(a known failure),update-lock(also fails on the base branch in this container) andsnapshot-restore(passes when rerun alone);omarchy-macpackage suite, rerun on the final commit;Second review, two rounds: it found no blockers. All verified findings are fixed: PID 1 must be systemd for a root to count as booted, hidden state never counts as a build, the probes are no longer vacuous on a Mac, and the detector restarts from BASH_SOURCE. One limit is documented: a caller in a private PID namespace looks like a build, so a test keeps
PrivatePIDs=out of the units. Fable re-check owed (initramfs selection).