Compare commits

..
Author SHA1 Message Date
David Heinemeier HanssonandClaude Fable 5 98a345c017 Update OEM comments to the renamed factory-reset command
Reference omarchy-system-factory-reset (was omarchy-reset-computer) in the
orchestrator comments and the plan.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-08 00:52:14 -07:00
David Heinemeier HanssonandClaude Fable 5 a478349ca9 Harness: prove the OEM keyboard step applies a non-default layout
Drive the OEM first-boot keyboard picker to English (UK) and assert the
installed system ends up with KEYMAP=uk and XKBLAYOUT=gb — proving the
deferred keyboard step actually applied a layout, not just rendered. UK keeps
every letter identical to US so the raw-keycode password still matches, and
the email's '@' (Shift+' under UK, not Shift+2) is typed with the UK keycode.
The console bootstrap now fetches-then-runs instead of piping, so it survives
the non-US layout the keyboard step installs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 23:13:53 -07:00
David Heinemeier HanssonandClaude Fable 5 7f1fdf2427 Reorder configurator: disk before keyboard, skip keyboard for OEM
The wizard now opens on disk selection; keyboard moves to after the install
mode is chosen and stays before the user step (so the LUKS passphrase is
still typed under the chosen layout). OEM installs skip keyboard and user
entirely — the machine's owner picks both at first boot — so the emitted
config just carries a default 'us' keymap as a placeholder.

The QEMU harness drives the new order and the OEM first-boot keyboard step.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 22:36:56 -07:00
David Heinemeier HanssonandClaude Fable 5 8aee09cb29 Second review pass: strip account fields, clear stale cidata inputs, await OEM finalization
Codex xhigh round 2:

- Strip account authentication fields (!users, !root-password,
  root_enc_password, auth_config account entries) from the archinstall config
  in OEM mode, not just user_credentials — a combined/legacy config could
  otherwise have archinstall create a provisioning account before OOBE.
- Clear stale OEM inputs (oem marker, credentials, optional files) from /root
  before copying a cidata drive, so a retried install in the same live session
  can't force a fresh drive back into OEM mode or reuse an old LUKS passphrase.
- The test harness waits for the OEM pending flag to clear before saving the
  base image, so it never snapshots a half-finalized first boot; it also
  handles the deliberately skipped mode picker on blank disks built against a
  pre-OEM runtime.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 19:03:49 -07:00
David Heinemeier HanssonandClaude Fable 5 e49ea2bc96 Keep provisioning credentials out of OEM installs and factory snapshots
Review findings from codex and Copilot:

- A rig-supplied credentials file in OEM mode now contributes only its LUKS
  passphrase: preserved users/root_enc_password fields would have created a
  hidden provisioning account despite OEM promising no user until first boot.
- The factory snapshot is taken writable, scrubbed of deployment credentials
  (staged authorized_keys, tailscale auth key and join unit, the dead OEM
  LUKS key and its initramfs drop-ins), then set read-only — a reset years
  later must not authorize the original deployment key or rejoin its tailnet.
- The missing-Node-tarball case is a hard install error on every install,
  not just OEM: the stash is what lets a factory reset finalize offline.
- The configurator's OEM gate checks the runtime package for the service
  unit as well as the setup binary.
- The test harness handles the deliberately skipped mode picker on blank
  disks when the bundled runtime lacks OEM support.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 18:09:10 -07:00
David Heinemeier HanssonandClaude Fable 5 445db32792 Make OEM state world-readable for user-context finalization
The Node tarball in /var/lib/omarchy/oem/packages is read by
omarchy-finalize-user running as the freshly created user; a 0700 directory
forced the offline install onto its network fallback. The only secret inside
(luks-key) is itself 0600 root.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 16:51:01 -07:00
David Heinemeier HanssonandClaude Fable 5 fbee4ba437 Isolate the test harness SSH identity from the local ssh-agent
A loaded agent offers its keys before the harness identity and can exhaust
the server's MaxAuthTries before the right key is ever tried; IdentitiesOnly
pins authentication to the per-run key.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 16:03:15 -07:00
David Heinemeier HanssonandClaude Fable 5 b5f7e96c70 Offer OEM mode only when the bundled runtime supports it
The configurator now peeks into the offline mirror's runtime package for
omarchy-oem-setup before offering the OEM install mode, so an ISO built
against a pre-OEM runtime can't start an install doomed to fail at the
staging phase (which still hard-checks as the backstop). Blank disks with no
OEM choice to offer skip the mode picker entirely, like the pre-OEM flow.

Also keep the test harness QMP socket in /tmp — unix socket paths cap at
~108 bytes, which nested test-run directories can exceed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 15:52:55 -07:00
David Heinemeier HanssonandClaude Fable 5 679edce2e3 Add OEM install mode and factory snapshots
OEM mode installs the entire system but defers user creation to first boot,
where the runtime's omarchy-oem-setup asks for the owner and lands them in the
already-installed system — and the same machinery arms omarchy-reset-computer.

The configurator's install-mode step gains an OEM choice, which required
moving the user step after mode selection (OEM skips it entirely). Autoinstall
rigs select OEM with an `oem` marker file on the cidata drive, which also
replaces the user_credentials.json requirement.

In the orchestrator, OEM swaps the user phases for a stage_oem_state phase:
it stashes the bundled Node tarball (every install, for offline factory
resets), arms omarchy-oem-setup.service in the target, and on encrypted
installs stages the throwaway LUKS passphrase — generated by InstallContext
when the input carries none — with a keyfile embedded in the UKI so boot
auto-unlocks until first-boot setup re-keys to the owner's password. The
install fails with a clear error if the bundled runtime lacks OEM support.

Every install now also ends with a read-only @factory snapshot of @ at the
btrfs top level — outside snapper's reach — which is what makes
omarchy-reset-computer a true factory reset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 15:41:04 -07:00
15 changed files with 476 additions and 668 deletions

No files matched your search

+71 -144
View File
@@ -14,8 +14,8 @@
# Usage: omarchy-iso-test [release/omarchy.iso] [options] # Usage: omarchy-iso-test [release/omarchy.iso] [options]
# #
# --encrypt Drive the encrypted install flow (default: unencrypted) # --encrypt Drive the encrypted install flow (default: unencrypted)
# --provision Drive the deferred-provisioning install flow: no user during install, the # --oem Drive the OEM install flow: no user during install, the
# first boot runs omarchy-provision-owner and creates it there # first boot runs omarchy-oem-setup and creates it there
# --reuse-base Skip the install phase if a base image already exists # --reuse-base Skip the install phase if a base image already exists
# --install-only Stop after producing the installed base image # --install-only Stop after producing the installed base image
# --sync-omarchy DIR Push DIR's test/acceptance into the guest before running # --sync-omarchy DIR Push DIR's test/acceptance into the guest before running
@@ -38,7 +38,7 @@ MEMORY=8192
INSTALL_TIMEOUT=2400 INSTALL_TIMEOUT=2400
BOOT_TIMEOUT=600 BOOT_TIMEOUT=600
ENCRYPT=false ENCRYPT=false
PROVISION=false OEM=false
REUSE_BASE=false REUSE_BASE=false
INSTALL_ONLY=false INSTALL_ONLY=false
KEEP_RUNNING=false KEEP_RUNNING=false
@@ -53,7 +53,7 @@ GUEST_HOSTNAME="omarchy-test"
while (($#)); do while (($#)); do
case "$1" in case "$1" in
--encrypt) ENCRYPT=true ;; --encrypt) ENCRYPT=true ;;
--provision) PROVISION=true ;; --oem) OEM=true ;;
--reuse-base) REUSE_BASE=true ;; --reuse-base) REUSE_BASE=true ;;
--install-only) INSTALL_ONLY=true ;; --install-only) INSTALL_ONLY=true ;;
--keep-running) KEEP_RUNNING=true ;; --keep-running) KEEP_RUNNING=true ;;
@@ -90,7 +90,7 @@ OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
BASE_NAME="$(basename "$ISO" .iso)" BASE_NAME="$(basename "$ISO" .iso)"
$ENCRYPT && BASE_NAME+="-encrypted" $ENCRYPT && BASE_NAME+="-encrypted"
$PROVISION && BASE_NAME+="-provision" $OEM && BASE_NAME+="-oem"
BASE_DIR="$REPO_DIR/test-runs/$BASE_NAME" BASE_DIR="$REPO_DIR/test-runs/$BASE_NAME"
RUN_DIR="$BASE_DIR/runs/$(date +%Y%m%d-%H%M%S)" RUN_DIR="$BASE_DIR/runs/$(date +%Y%m%d-%H%M%S)"
BASE_DISK="$BASE_DIR/base.qcow2" BASE_DISK="$BASE_DIR/base.qcow2"
@@ -606,133 +606,112 @@ audio-panel|meta_l-ctrl-a|omarchy-keyboard-panel|omarchy.audio'
drive_configurator() { drive_configurator() {
log "Driving the installer wizard" log "Driving the installer wizard"
# A greeter (animated logo + tagline) opens the installer; Return begins. # Disk first (the keyboard step moved after mode selection, and OEM skips it).
wait_for_screen "Opinionated" 300 wait_for_screen "install disk" 300
capture_console "success-installer-00-greeter" capture_console "success-installer-01-install-disk"
press ret press ret # the single virtio disk
# Keyboard is the first screen. Ctrl+C there is the hidden entry into deferred provisioning # A blank disk shows the mode picker only when the bundled runtime supports
# mode; a normal install just selects the layout. # OEM mode; otherwise the wizard goes straight to the overwrite confirm.
wait_for_screen "keyboard layout" 300 wait_for_screen "installation mode\|recovery possible" 60
capture_console "success-installer-01-keyboard-layout" if ocr_screen | grep -qi "installation mode"; then
capture_console "success-installer-02-install-mode"
if $PROVISION; then if $OEM; then
press ctrl-c # arm "prepare for another owner" press down # "OEM install" sits below "Full disk install" on a blank disk
wait_for_screen "another owner" 30
capture_console "success-installer-02-prepare-confirm"
press ret # "Yes, prepare for another owner" is the affirmative default
# Jumps straight to disk selection, then the overwrite confirm.
wait_for_screen "install disk" 60
capture_console "success-installer-03-prepare-install-disk"
press ret
wait_for_screen "recovery possible" 60
capture_console "success-installer-04-prepare-disk-warning-encrypted"
if ! $ENCRYPT; then
press ctrl-c
wait_for_screen "without encryption" 30
capture_console "success-installer-05-prepare-disk-warning-unencrypted"
fi fi
press ret press ret
elif $OEM; then
capture_console "failure-installer-no-oem-choice"
echo "OEM flow requested but this ISO does not offer OEM mode" >&2
return 1
fi
wait_for_screen "recovery possible" 60
capture_console "success-installer-03-disk-warning-encrypted"
if ! $ENCRYPT; then
press ctrl-c # toggles the confirm to the unencrypted flow
wait_for_screen "without encryption" 30
capture_console "success-installer-04-disk-warning-unencrypted"
fi
press ret
if $OEM; then
# OEM installs skip the keyboard and user steps; the install starts now.
sleep 2 sleep 2
capture_console "success-installer-13-install-started" capture_console "success-installer-13-install-started"
return 0 return 0
fi fi
wait_for_screen "keyboard layout" 60
capture_console "success-installer-05-keyboard-layout"
press ret # English (US) is preselected press ret # English (US) is preselected
# Normal flow: user step comes before disk selection.
wait_for_screen "Username" 120 wait_for_screen "Username" 120
type_text "$GUEST_USER" type_text "$GUEST_USER"
capture_console "success-installer-02-username" capture_console "success-installer-06-username"
press ret press ret
wait_for_screen "Password" 60 wait_for_screen "Password" 60
type_text "$GUEST_PASSWORD" type_text "$GUEST_PASSWORD"
capture_console "success-installer-03-password" capture_console "success-installer-07-password"
press ret press ret
wait_for_screen "Must match" 60 wait_for_screen "Must match" 60
type_text "$GUEST_PASSWORD" type_text "$GUEST_PASSWORD"
capture_console "success-installer-04-password-confirmation" capture_console "success-installer-08-password-confirmation"
press ret press ret
wait_for_screen "Full name" 60 wait_for_screen "Full name" 60
type_text "Omarchy Test" type_text "Omarchy Test"
capture_console "success-installer-05-full-name" capture_console "success-installer-09-full-name"
press ret press ret
wait_for_screen "Email address" 60 wait_for_screen "Email address" 60
type_text "test@omarchy.org" type_text "test@omarchy.org"
capture_console "success-installer-06-email" capture_console "success-installer-10-email"
press ret press ret
wait_for_screen "Hostname" 60 wait_for_screen "Hostname" 60
type_text "$GUEST_HOSTNAME" type_text "$GUEST_HOSTNAME"
capture_console "success-installer-07-hostname" capture_console "success-installer-11-hostname"
press ret press ret
wait_for_screen "Timezone" 180 # tzupdate geo-guess can take a moment wait_for_screen "Timezone" 180 # tzupdate geo-guess can take a moment
capture_console "success-installer-08-timezone" capture_console "success-installer-12-timezone"
press ret press ret
wait_for_screen "look right" 60 wait_for_screen "look right" 60
capture_console "success-installer-09-review" capture_console "success-installer-13-review"
press ret
wait_for_screen "install disk" 60
capture_console "success-installer-10-install-disk"
press ret # the single virtio disk
wait_for_screen "installation mode\|recovery possible" 60
if ocr_screen | grep -qi "installation mode"; then
capture_console "success-installer-11-install-mode"
press ret # "Full disk install" is preselected
fi
wait_for_screen "recovery possible" 60
capture_console "success-installer-12-disk-warning-encrypted"
if ! $ENCRYPT; then
press ctrl-c # toggles the confirm to the unencrypted flow
wait_for_screen "without encryption" 30
capture_console "success-installer-13-disk-warning-unencrypted"
fi
press ret press ret
sleep 2 sleep 2
capture_console "success-installer-14-install-started" capture_console "success-installer-14-install-started"
} }
# The deferred-provisioning first boot runs the user form on tty1 (omarchy-provision-owner) before # The OEM first boot runs the user form on tty1 (omarchy-oem-setup) before
# SDDM. Encrypted deferred-provisioning installs auto-unlock from the staged keyfile, so there # SDDM. Encrypted OEM installs auto-unlock from the staged keyfile, so there
# is no LUKS prompt to answer here either way. # is no LUKS prompt to answer here either way.
drive_provision_owner() { drive_oem_setup() {
log "Driving the deferred-provisioning first-boot setup" log "Driving the OEM first-boot setup"
# Deferred provisioning defers the keyboard step to first boot; it comes before the user form. # OEM defers the keyboard step to first boot; it comes before the user form.
# Pick English (UK) (one row below the preselected English (US), which leads # Pick English (UK) (one row above the preselected English (US)) so the
# the list) so the verifier can prove the deferred step applied a non-default # verifier can prove the deferred step applied a non-default layout — UK
# layout — UK leaves every letter identical to US, so the typed password (sent # leaves every letter identical to US, so the typed password (sent as raw
# as raw keycodes) still matches the literal one the harness pipes to sudo. # keycodes) still matches the literal one the harness pipes to sudo.
# A greeter (animated logo + tagline) opens first boot; Return begins. wait_for_screen "keyboard layout" 600
wait_for_screen "Opinionated" 600 press up
capture_console "success-provision-00-greeter" capture_console "success-oem-01-keyboard-layout-uk"
press ret
wait_for_screen "keyboard layout" 120
press down
capture_console "success-provision-01-keyboard-layout-uk"
press ret press ret
wait_for_screen "Username" 120 wait_for_screen "Username" 120
capture_console "success-provision-02-username" capture_console "success-oem-02-username"
type_text "$GUEST_USER" type_text "$GUEST_USER"
press ret press ret
wait_for_screen "Password" 60 wait_for_screen "Password" 60
type_text "$GUEST_PASSWORD" type_text "$GUEST_PASSWORD"
capture_console "success-provision-03-password" capture_console "success-oem-03-password"
press ret press ret
wait_for_screen "Conf *irm" 60 wait_for_screen "Conf *irm" 60
@@ -750,28 +729,16 @@ drive_provision_owner() {
type_text "test" type_text "test"
press shift-apostrophe press shift-apostrophe
type_text "omarchy.org" type_text "omarchy.org"
capture_console "success-provision-04-email" capture_console "success-oem-04-email"
press ret
# Hostname is deferred to first boot too.
wait_for_screen "Hostname" 60
type_text "$GUEST_HOSTNAME"
capture_console "success-provision-05-hostname"
press ret
# Timezone is deferred to first boot too; accept the geo-guessed default.
# Generous timeout: the tzupdate geo-guess over first-boot networking can lag.
wait_for_screen "Timezone" 180
capture_console "success-provision-06-timezone"
press ret press ret
wait_for_screen "look right" 60 wait_for_screen "look right" 60
capture_console "success-provision-07-review" capture_console "success-oem-05-review"
press ret press ret
# Finalization (offline Node unpack, LUKS re-key on encrypted installs) # Finalization (offline Node unpack, LUKS re-key on encrypted installs)
# runs before SDDM appears. # runs before SDDM appears.
capture_console "success-provision-08-finalizing" capture_console "success-oem-06-finalizing"
} }
wait_for_install() { wait_for_install() {
@@ -788,15 +755,6 @@ wait_for_install() {
return 0 return 0
fi fi
# Deferred-provisioning installs skip the celebration and reboot on their own
# (no Reboot Now prompt); the first-boot greeter tagline appearing means the
# install finished and rebooted into setup.
if $PROVISION && grep -qi "Opinionated" <<<"$text"; then
log "Install finished and auto-rebooted into first-boot setup."
capture_console "success-installer-15-autoreboot"
return 0
fi
if grep -qi "installation stopped" <<<"$text"; then if grep -qi "installation stopped" <<<"$text"; then
capture_console "failure-installer-installation-stopped" capture_console "failure-installer-installation-stopped"
echo "Install failed — screenshot saved to $RUN_DIR" >&2 echo "Install failed — screenshot saved to $RUN_DIR" >&2
@@ -903,7 +861,7 @@ EOF
capture_console "success-first-boot-05-bootstrap-command" capture_console "success-first-boot-05-bootstrap-command"
press ret press ret
wait_for_ssh 360 "failure-first-boot-ssh-timeout" wait_for_ssh 180 "failure-first-boot-ssh-timeout"
capture_console "success-first-boot-06-bootstrap-complete" capture_console "success-first-boot-06-bootstrap-complete"
kill "$HTTP_PID" 2>/dev/null || true kill "$HTTP_PID" 2>/dev/null || true
@@ -983,61 +941,30 @@ install_phase() {
drive_configurator drive_configurator
wait_for_install wait_for_install
if $PROVISION; then if $OEM; then
drive_provision_owner drive_oem_setup
elif $ENCRYPT; then elif $ENCRYPT; then
unlock_luks unlock_luks
fi fi
bootstrap_ssh bootstrap_ssh
# SSH can come up (console bootstrap logs in on a spare TTY) while # SSH can come up (console bootstrap logs in on a spare TTY) while
# omarchy-provision-owner is still finalizing the user and re-keying LUKS. Saving # omarchy-oem-setup is still finalizing the user and re-keying LUKS. Saving
# the base mid-finalization produces a flaky image, so wait for the pending # the base mid-finalization produces a flaky image, so wait for the pending
# flag to clear before powering off. # flag to clear before powering off.
if $PROVISION; then if $OEM; then
log "Waiting for provisioning first-boot setup to finish" log "Waiting for OEM first-boot setup to finish"
local waited=0 rc local waited=0
while true; do while ssh_guest "test -f /var/lib/omarchy/oem/pending" 2>/dev/null; do
# Capture rc via `|| rc=$?` so a non-zero result doesn't trip `set -e`
# (this command is intentionally allowed to "fail" — that's the signal).
rc=0
ssh_guest "test -f /var/lib/omarchy/provisioning/pending" 2>/dev/null || rc=$?
# rc 0 = flag still present; rc 255 = SSH not up yet (finalization may
# still be running) — keep waiting. Only a clean "file absent" (rc 1)
# means provisioning finished, so we don't snapshot mid-finalization on a
# transient SSH blip.
(( rc == 0 || rc == 255 )) || break
if ((waited >= 900)); then if ((waited >= 900)); then
capture_console "failure-provision-finalization-timeout" capture_console "failure-oem-finalization-timeout"
echo "Timed out waiting for provisioning first-boot setup to complete" >&2 echo "Timed out waiting for OEM first-boot setup to complete" >&2
return 1 return 1
fi fi
sleep 10 sleep 10
((waited += 10)) ((waited += 10))
done done
capture_console "success-oem-06-setup-complete"
# The owner's hostname and timezone are set at first boot now, not baked
# into the install — confirm they actually landed on the running system.
# Hostname is deterministic (we typed it), so a mismatch is a hard failure;
# timezone is geo-guessed, so just report what landed.
local got_host="" got_tz=""
got_host=$(ssh_guest "cat /etc/hostname" 2>/dev/null | tr -d '\r\n') || got_host=""
got_tz=$(ssh_guest "timedatectl show -p Timezone --value" 2>/dev/null | tr -d '\r\n') || got_tz=""
if [[ $got_host != "$GUEST_HOSTNAME" ]]; then
capture_console "failure-provision-hostname-not-applied"
echo "First-boot hostname is '${got_host:-<empty>}', expected '$GUEST_HOSTNAME'" >&2
return 1
fi
log "hostname applied at first boot: $got_host"
if [[ -n $got_tz && $got_tz != "UTC" ]]; then
log "timezone applied at first boot: $got_tz"
else
echo "WARN: timezone is '${got_tz:-<empty>}' (expected the owner's choice, not UTC)" >&2
fi
# Deferred first-boot setup hands straight off to SDDM once the oneshot
# service exits — no celebration screen, no Start Omarchy button to confirm.
capture_console "success-provision-09-handoff"
fi fi
ssh_guest "echo $GUEST_PASSWORD | sudo -S cat /var/log/omarchy-install-timing.json 2>/dev/null" \ ssh_guest "echo $GUEST_PASSWORD | sudo -S cat /var/log/omarchy-install-timing.json 2>/dev/null" \
-26
View File
@@ -139,7 +139,6 @@ sed -i -E '/^(linux|broadcom-wl)$/d' "$build_cache_dir/packages.x86_64"
# pulls the published omarchy* from the network mirror like any other package. # pulls the published omarchy* from the network mirror like any other package.
if [[ -d /omarchy-source ]]; then if [[ -d /omarchy-source ]]; then
base_pkg_lists=(/omarchy-source/install/omarchy-base.packages /omarchy-source/install/omarchy-other.packages) base_pkg_lists=(/omarchy-source/install/omarchy-base.packages /omarchy-source/install/omarchy-other.packages)
setup_form=/omarchy-source/install/provisioning/setup-form.sh
else else
# Pull the same package lists out of the freshly-downloaded Omarchy runtime # Pull the same package lists out of the freshly-downloaded Omarchy runtime
# package so we don't need a local checkout in the non-local-source path. # package so we don't need a local checkout in the non-local-source path.
@@ -155,37 +154,12 @@ else
mkdir -p /tmp/omarchy-pkglists mkdir -p /tmp/omarchy-pkglists
bsdtar -xf "$omarchy_pkg" -C /tmp/omarchy-pkglists usr/share/omarchy/install/omarchy-base.packages usr/share/omarchy/install/omarchy-other.packages bsdtar -xf "$omarchy_pkg" -C /tmp/omarchy-pkglists usr/share/omarchy/install/omarchy-base.packages usr/share/omarchy/install/omarchy-other.packages
base_pkg_lists=(/tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-base.packages /tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-other.packages) base_pkg_lists=(/tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-base.packages /tmp/omarchy-pkglists/usr/share/omarchy/install/omarchy-other.packages)
# Extracted on its own, tolerating a miss: bsdtar exits non-zero for a member
# it can't find, so asking for this alongside the package lists would abort the
# build here (set -e) with a bare "Not found in archive" instead of the
# actionable error below.
bsdtar -xf "$omarchy_pkg" -C /tmp/omarchy-pkglists usr/share/omarchy/install/provisioning/setup-form.sh 2>/dev/null || true
setup_form=/tmp/omarchy-pkglists/usr/share/omarchy/install/provisioning/setup-form.sh
fi fi
mkdir -p "$build_cache_dir/airootfs/usr/share/omarchy-iso" mkdir -p "$build_cache_dir/airootfs/usr/share/omarchy-iso"
cp "${base_pkg_lists[0]}" "$build_cache_dir/airootfs/usr/share/omarchy-iso/omarchy-base.packages" cp "${base_pkg_lists[0]}" "$build_cache_dir/airootfs/usr/share/omarchy-iso/omarchy-base.packages"
cp "${base_pkg_lists[1]}" "$build_cache_dir/airootfs/usr/share/omarchy-iso/omarchy-other.packages" cp "${base_pkg_lists[1]}" "$build_cache_dir/airootfs/usr/share/omarchy-iso/omarchy-other.packages"
# The configurator's setup form comes from the runtime this ISO bundles, so the
# installer and the first-boot setup that finishes a deferred install can never
# disagree. A runtime predating the split ships no such file, which would leave
# the configurator with no prompts at all.
if [[ ! -f $setup_form ]]; then
if [[ -d /omarchy-source ]]; then
echo "ERROR: the --local-source checkout ships no install/provisioning/setup-form.sh" >&2
remedy="Update the checkout to a revision carrying the shared setup form."
else
echo "ERROR: $OMARCHY_RUNTIME_PACKAGE does not ship install/provisioning/setup-form.sh" >&2
remedy="Publish a runtime carrying the shared setup form, or build with --local-source against a checkout that has it."
fi
echo " The configurator sources its prompts from that file, so this ISO" >&2
echo " would boot into an installer with no questions to ask." >&2
echo " $remedy" >&2
exit 1
fi
cp "$setup_form" "$build_cache_dir/airootfs/usr/share/omarchy-iso/setup-form.sh"
# Collect every package we want available in the offline mirror. # Collect every package we want available in the offline mirror.
declare -a all_packages declare -a all_packages
mapfile -t all_packages < <( mapfile -t all_packages < <(
+1 -11
View File
@@ -101,16 +101,6 @@ else
./configurator ./configurator
fi fi
# Deferred-provisioning installs skip the celebration/reboot prompt and reboot on
# their own — the owner completes setup at first boot. Signalled by the config's
# defer_provisioning flag (interactive) or the defer-provisioning marker (cidata).
# Parse the flag with jq (the same JSON semantics the orchestrator uses) rather
# than a line regex, so a reformatted config can't read as a direct install.
if [[ -f /root/defer-provisioning ]] ||
[[ "$(jq -r '.omarchy_install.defer_provisioning // false' /root/user_configuration.json 2>/dev/null)" == "true" ]]; then
export OMARCHY_UI_DEFER_PROVISIONING=yes
fi
# The foreground dashboard is now the sole visible install UI owner. It starts # The foreground dashboard is now the sole visible install UI owner. It starts
# the actual installer as a non-interactive child, logs child output, waits for # the actual installer as a non-interactive child, logs child output, waits for
# completion, then renders the final installed-time/reboot prompt itself. # completion, then renders the final installed-time/reboot prompt itself.
@@ -128,4 +118,4 @@ rm -f /run/omarchy-install/state.json
--encrypt-file /root/user_encrypt_installation.txt \ --encrypt-file /root/user_encrypt_installation.txt \
--authorized-keys-file /root/authorized_keys \ --authorized-keys-file /root/authorized_keys \
--tailscale-authkey-file /root/tailscale_authkey \ --tailscale-authkey-file /root/tailscale_authkey \
--defer-provisioning-file /root/defer-provisioning --oem-file /root/oem
+172 -227
View File
@@ -9,21 +9,6 @@ OMARCHY_SETTINGS_PACKAGE="${OMARCHY_SETTINGS_PACKAGE:-omarchy-settings}"
LOGO_PATH="$OMARCHY_PATH/logo.txt" LOGO_PATH="$OMARCHY_PATH/logo.txt"
# The setup form — keyboard, account, hostname, and timezone questions, plus the
# rules their answers are checked against — shared verbatim with the first-boot
# owner setup that finishes a deferred install. build-iso.sh vendors it out of
# the runtime package this ISO bundles, so the two can never offer different
# layouts or accept different usernames. On the ISO that vendored copy is what
# loads; a dry run outside the ISO falls back to the omarchy checkout
# bin/omarchy-iso-configurator already points OMARCHY_PATH at.
SETUP_FORM="${SETUP_FORM:-/usr/share/omarchy-iso/setup-form.sh}"
[[ -r $SETUP_FORM ]] || SETUP_FORM="$OMARCHY_PATH/install/provisioning/setup-form.sh"
if [[ ! -r $SETUP_FORM ]]; then
echo "ERROR: shared setup form not found at $SETUP_FORM" >&2
exit 1
fi
source "$SETUP_FORM"
LOGO_WIDTH=$(awk '{ if (length > max) max = length } END { print max+0 }' "$LOGO_PATH") LOGO_WIDTH=$(awk '{ if (length > max) max = length } END { print max+0 }' "$LOGO_PATH")
export GUM_CONFIRM_PROMPT_FOREGROUND="6" export GUM_CONFIRM_PROMPT_FOREGROUND="6"
@@ -53,111 +38,12 @@ measure_terminal() {
} }
measure_terminal measure_terminal
# The live VT resizes late during boot: tty1 starts as the 80-column boot
# console and only grows once the kernel framebuffer/KMS takes over (noticeably
# late in VMs). The logo is wider than 80 columns, so a first draw against that
# transient narrow console wraps the logo ("smushed") and can't center it
# (padding clamps to 0, so it hugs the left). A terminal emulator (or sudo's
# pty) has the same problem the other way: it reports a stale 24x80 for a few
# hundred ms after start before its real winsize is set. Either way, hold the
# first draw until the width settles at (or above) the logo width. A real VT
# that never widens (e.g. nomodeset) still proceeds after the cap.
wait_for_stable_terminal() {
local width last="" stable=0 waited=0
while (( waited < 5000 )); do
width=$(stty size 2>/dev/null </dev/tty | awk '{print $2}')
[[ $width =~ ^[0-9]+$ ]] || width=0
if [[ $width == "$last" ]] && (( width >= LOGO_WIDTH )); then
(( ++stable >= 3 )) && break
else
stable=0
fi
last=$width
sleep 0.2
(( waited += 200 ))
done
}
clear_logo() { clear_logo() {
measure_terminal measure_terminal
printf "\033[H\033[2J" printf "\033[H\033[2J"
gum style --foreground 2 --padding "1 0 0 $PADDING_LEFT" "$(<"$LOGO_PATH")" gum style --foreground 2 --padding "1 0 0 $PADDING_LEFT" "$(<"$LOGO_PATH")"
} }
# Vertically-centered welcome shown once before the keyboard step — the same
# frame the deferred-provisioning first boot opens on, so install and first boot
# bookend the setup identically. Logo, the Omarchy tagline, and a single button,
# centered like the boot logo. No animation.
greeter() {
measure_terminal
local rows logo_h content_h top cols logo_row tagline_row hint_row
local tagline hint tpad hpad anim
cols=$TERM_WIDTH
rows=$(stty size 2>/dev/null </dev/tty | awk '{print $1}')
[[ $rows =~ ^[0-9]+$ ]] || rows=${LINES:-24}
logo_h=$(wc -l <"$LOGO_PATH")
# logo + blank + tagline + blank + hint
content_h=$((logo_h + 4))
top=$(((rows - content_h) / 2))
(( top < 0 )) && top=0
logo_row=$((top + 1))
tagline_row=$((top + logo_h + 2))
hint_row=$((top + logo_h + 4))
printf '\033[?25l\033[H\033[2J'
printf '\033[%d;1H' "$logo_row"
gum style --foreground 2 --padding "0 0 0 $PADDING_LEFT" "$(<"$LOGO_PATH")"
tagline="Beautiful, Modern & Opinionated Linux by DHH"
tpad=$(((cols - ${#tagline}) / 2)); (( tpad < 0 )) && tpad=0
printf '\033[%d;%dH%s' "$tagline_row" "$((tpad + 1))" "$tagline"
hint="Press Return to Start Install"
hpad=$(((cols - ${#hint}) / 2)); (( hpad < 0 )) && hpad=0
printf '\033[%d;%dH\033[2m%s\033[0m' "$hint_row" "$((hpad + 1))" "$hint"
# ColorShift the logo: a green base (indexed color 2) with a cyan accent (6)
# drifting through, settling on green. Indexed ANSI colors, not hex — the
# framebuffer console can't render tte's truecolor faithfully (it crushes the
# palette to a muddy lavender), but the 16 indexed colors map to the Tokyo
# Night palette and render true. One long-running invocation (many cycles) so
# it never restarts — a restart is what flashed. The effect reads from
# /dev/null so it never swallows the Return; --reuse-canvas paints upward from
# the saved cursor, anchored one row below the logo.
if command -v tte >/dev/null 2>&1; then
printf '\033[%d;1H\0337' "$((logo_row + logo_h))"
# Run tte directly (not inside a `while` subshell) so $anim is tte's own
# PID: killing a wrapping subshell would orphan tte, which then keeps
# painting the logo over the keyboard step. --cycles is high enough that it
# never ends on its own before Return.
tte -i "$LOGO_PATH" \
--canvas-width "$cols" \
--anchor-text c \
--frame-rate 60 \
--reuse-canvas \
colorshift \
--gradient-stops 2 10 6 10 \
--gradient-frames 3 \
--cycles 1000 \
--final-gradient-stops 2 \
</dev/null >/dev/tty 2>/dev/null &
anim=$!
fi
IFS= read -r _ </dev/tty || true
# Tolerate tte's kill signal in `wait` so a future `set -e` here can't abort.
[[ -n ${anim:-} ]] && { kill "$anim" 2>/dev/null; wait "$anim" 2>/dev/null || true; }
# tte leaves the tty in raw/no-echo mode when killed; restore it or the gum
# prompts in the keyboard step that follows silently die.
stty sane </dev/tty 2>/dev/null || true
# Reset the screen so the leftover animation frame doesn't linger under the
# keyboard step that follows.
printf '\033[0m\033[H\033[2J\033[?25h'
}
abort() { abort() {
gum style "${1:-Aborted installation}" gum style "${1:-Aborted installation}"
echo echo
@@ -187,37 +73,59 @@ notice() {
# STEP 1: KEYBOARD LAYOUT # STEP 1: KEYBOARD LAYOUT
keyboard_form() { keyboard_form() {
# The Ctrl+C hint sits directly under the header (no blank line between), step "Let's setup your machine..."
# matching the disk-overwrite screen's unencrypted offer. Ctrl+C on the first keyboards=$'Azerbaijani|azerty
# screen is the hidden entry into deferred provisioning; $1 is "true" only for that first Belarusian|by
# invocation, so the review-loop re-edit can't flip a user install into it. Belgian|be-latin1
local allow_defer_provisioning="${1:-false}" Bosnian|ba
local status Bulgarian|bg-cp1251
Croatian|croat
while true; do Czech|cz
clear_logo Danish|dk-latin1
echo Dutch|nl
say "Let's setup your machine..." English (UK)|uk
if $allow_defer_provisioning; then English (US)|us
say --foreground 8 "Press Ctrl+C to prepare this machine for another owner." English (US, Dvorak)|dvorak
fi English (US, Colemak)|colemak
echo Estonian|et
Finnish|fi
omarchy_prompt_keyboard && status=0 || status=$? French|fr
((status == 0)) && break French (Canada)|cf
French (Switzerland)|fr_CH
# Esc means "back", and nothing precedes the first screen, so re-ask. Georgian|ge
((status == OMARCHY_FORM_BACK)) && continue German|de
German (Switzerland)|de_CH-latin1
if $allow_defer_provisioning && ((status == OMARCHY_FORM_SIGNAL)); then Greek|gr
if confirm_prepare_for_another_owner; then Hebrew|il
defer_provisioning=true Hungarian|hu
return 0 Icelandic|is-latin1
fi Irish|ie
continue # declined: back to the keyboard picker Italian|it
fi Japanese|jp106
abort Kazakh|kazakh
done Khmer (Cambodia)|khmer
Kyrgyz|kyrgyz
Lao|la-latin1
Latvian|lv
Lithuanian|lt
Macedonian|mk-utf
Norwegian|no-latin1
Polish|pl
Portuguese|pt-latin1
Portuguese (Brazil)|br-abnt2
Romanian|ro
Russian|ru
Serbian|sr-latin
Slovak|sk-qwertz
Slovenian|slovene
Spanish|es
Spanish (Latin American)|la-latin1
Swedish|sv-latin1
Tajik|tj_alt-UTF8
Turkish|trq
Ukrainian|ua'
choice=$(printf '%s\n' "$keyboards" | cut -d'|' -f1 | gum choose --height 10 --selected "English (US)" --header "Select keyboard layout") || abort
keyboard=$(printf '%s\n' "$keyboards" | awk -F'|' -v c="$choice" '$1==c{print $2; exit}')
# Only attempt to load keyboard layout if we're on a real console # Only attempt to load keyboard layout if we're on a real console
# loadkeys only works on Linux virtual consoles (tty), not in terminal emulators # loadkeys only works on Linux virtual consoles (tty), not in terminal emulators
@@ -226,54 +134,73 @@ keyboard_form() {
fi fi
} }
# Ctrl+C on the first screen offers to prepare the machine for another owner. # Keyboard and user run after the install mode is chosen. OEM installs skip
# Confirm it before committing, so an accidental Ctrl+C doesn't silently switch # both — the machine's first owner picks their keyboard and creates their user
# the whole install. # in the first-boot setup, so the OEM operator sets nothing user-specific.
confirm_prepare_for_another_owner() {
clear_logo
echo
say "This prepares the machine for another owner."
say --foreground 8 "The system installs now, but setup is delayed until first boot."
echo
gum confirm --affirmative "Yes, prepare for another owner" --negative "No, keep setting up" \
"Prepare this machine for another owner?"
}
# The user step. Deferred-provisioning installs skip it entirely — the machine's first owner
# picks their keyboard and creates their user in the first-boot setup, so the
# operator sets nothing user-specific.
user_form() { user_form() {
step "Let's setup your user account..." step "Let's setup your user account..."
# Each prompt reports 0 (set), OMARCHY_FORM_BACK (Esc), or OMARCHY_FORM_SIGNAL while true; do
# (Ctrl+C). Both non-zero cases unwind to user_step, which decides what they username=$(gum input --placeholder "Alphanumeric without spaces (like dhh)" --prompt.foreground="#845DF9" --prompt "Username> ") || abort
# mean here; the form itself never aborts.
omarchy_prompt_username || return $?
omarchy_prompt_password || return $?
# Hash the password with SHA-512 crypt ($6$), which is what openssl passwd offers if [[ "$username" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then
if [[ "$username" =~ ^(root|bin|daemon|mail|ftp|http|nobody|dbus|systemd-coredump|systemd-network|systemd-oom|systemd-journal-remote|systemd-resolve|systemd-timesync|tss|uuidd|alpm|git|avahi|cups|lp|_talkd|polkitd|rtkit|qemu|brltty|gluster|rpc|libvirt-qemu|pcscd|nvidia-persistenced|sddm)$ ]] ; then
notice "Username is reserved for system" 1
else
break
fi
else
notice "Username must be alphanumeric with no spaces" 1
fi
done
while true; do
password=$(gum input --placeholder "Used for user + root, and disk encryption when enabled" --prompt.foreground="#845DF9" --password --prompt "Password> ") || abort
password_confirmation=$(gum input --placeholder "Must match the password you just typed" --prompt.foreground="#845DF9" --password --prompt "Confirm> ") || abort
if [[ -n "$password" && "$password" == "$password_confirmation" ]]; then
break
elif [[ -z "$password" ]]; then
notice "Your password can't be blank!" 1
else
notice "Passwords didn't match!" 1
fi
done
# Hash the password using yescrypt
password_hash=$(printf '%s' "$password" | openssl passwd -6 -stdin) password_hash=$(printf '%s' "$password" | openssl passwd -6 -stdin)
omarchy_prompt_identity || return $? full_name=$(gum input --placeholder "Used for git authentication (hit return to skip)" --prompt.foreground="#845DF9" --prompt "Full name> ")
omarchy_prompt_hostname || return $? email_address=$(gum input --placeholder "Used for git authentication (hit return to skip)" --prompt.foreground="#845DF9" --prompt "Email address> ")
omarchy_prompt_timezone || return $?
while true; do
hostname=$(gum input --placeholder "Letters, digits, and dashes (or return for 'omarchy')" --prompt.foreground="#845DF9" --prompt "Hostname> ")
if [[ "$hostname" =~ ^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?$ ]]; then
break
elif [[ -z $hostname ]]; then
hostname="omarchy"
break
else
notice "Hostname must be 1-63 letters, digits, or dashes, and cannot start or end with a dash" 1
fi
done
# Pick timezone
geo_guessed_timezone=$(tzupdate -p 2>/dev/null)
if [[ -n $geo_guessed_timezone ]]; then
timezone=$(timedatectl list-timezones | gum choose --height 10 --selected "$geo_guessed_timezone" --header "Timezone") || abort
else
timezone=$(timedatectl list-timezones | gum filter --height 10 --header "Timezone") || abort
fi
} }
user_step() { user_step() {
local status user_form
while true; do while true; do
user_form && status=0 || status=$?
if ((status != 0)); then
# Esc unwinds to the start of the form. Ctrl+C has no side channel in the
# user step (only the keyboard and disk screens give it a meaning), so it
# keeps its long-standing behaviour of ending the install.
((status == OMARCHY_FORM_BACK)) || abort
keyboard_form
continue
fi
# Add manual padding since gum table -p doesn't respect padding # Add manual padding since gum table -p doesn't respect padding
echo -e "Field,Value echo -e "Field,Value
Username,$username Username,$username
@@ -290,6 +217,7 @@ Keyboard,$keyboard" |
break break
else else
keyboard_form keyboard_form
user_form
fi fi
done done
} }
@@ -421,14 +349,14 @@ wait_for_device() {
# Save the configurator answers the installer consumes: git identity and # Save the configurator answers the installer consumes: git identity and
# encryption choice as plain files, account details as archinstall credentials. # encryption choice as plain files, account details as archinstall credentials.
# Deferred-provisioning installs defer the user to first boot: no credentials, and on encrypted # OEM installs defer the user to first boot: no credentials, and on encrypted
# targets the orchestrator generates a throwaway LUKS passphrase itself. # targets the orchestrator generates a throwaway LUKS passphrase itself.
write_user_files() { write_user_files() {
echo "$full_name" >user_full_name.txt echo "$full_name" >user_full_name.txt
echo "$email_address" >user_email_address.txt echo "$email_address" >user_email_address.txt
printf '%s\n' "$encrypt_installation" >user_encrypt_installation.txt printf '%s\n' "$encrypt_installation" >user_encrypt_installation.txt
if $defer_provisioning; then if $oem_install; then
cat <<-_EOF_ >user_credentials.json cat <<-_EOF_ >user_credentials.json
{ {
"users": [] "users": []
@@ -507,9 +435,8 @@ run_partition_decide() {
bl_part=$(detect_bitlocker || true) bl_part=$(detect_bitlocker || true)
if [[ -n "$bl_part" ]]; then if [[ -n "$bl_part" ]]; then
say --foreground 1 "BitLocker signature detected on $bl_part." say --foreground 1 "BitLocker signature detected on $bl_part."
say "Turn BitLocker off in Windows and wait for the drive to finish decrypting, then try again." say "Suspend or disable BitLocker in Windows before installing alongside it."
say "Suspending BitLocker is not enough — the drive stays encrypted." abort "Aborted: BitLocker is active on this disk."
abort "Aborted: BitLocker is enabled on this disk."
fi fi
# Omarchy always creates its own dedicated ESP in free space and never # Omarchy always creates its own dedicated ESP in free space and never
@@ -854,6 +781,25 @@ open_partition_tool() {
sleep 1 sleep 1
} }
# OEM mode needs the bundled runtime package to ship the first-boot setup
# (omarchy-oem-setup); an ISO built against an older runtime must not offer a
# mode whose install would fail at the staging phase. Peek into the offline
# mirror's runtime package once; outside the ISO (dry runs) offer the mode.
oem_supported() {
if [[ -z ${OEM_SUPPORTED:-} ]]; then
local mirror=/var/cache/omarchy/mirror/offline pkg
OEM_SUPPORTED=true
if [[ -d $mirror ]]; then
pkg=$(ls "$mirror/$OMARCHY_RUNTIME_PACKAGE"-[0-9]*.pkg.tar.zst 2>/dev/null | head -1)
if [[ -z $pkg ]] || ! tar -tf "$pkg" usr/bin/omarchy-oem-setup \
usr/share/omarchy/install/oem/omarchy-oem-setup.service &>/dev/null; then
OEM_SUPPORTED=false
fi
fi
fi
[[ $OEM_SUPPORTED == true ]]
}
# If the disk has no partition table or no unallocated free space, the only # If the disk has no partition table or no unallocated free space, the only
# viable paths write the whole disk, so the free-space mode is not offered. # viable paths write the whole disk, so the free-space mode is not offered.
requires_full_disk_install() { requires_full_disk_install() {
@@ -885,6 +831,11 @@ install_mode_form() {
if [[ -d /sys/firmware/efi ]] && ! $full_disk_only; then if [[ -d /sys/firmware/efi ]] && ! $full_disk_only; then
choices+=("Free space install (alongside existing data)") choices+=("Free space install (alongside existing data)")
fi fi
# OEM: install the whole system now, defer user setup to the machine's
# first boot — for machines built to be sold or handed on.
if oem_supported; then
choices+=("OEM install (new owner creates their user on first boot)")
fi
choices+=("Choose a different disk") choices+=("Choose a different disk")
step "Let's select how to install Omarchy..." step "Let's select how to install Omarchy..."
@@ -930,10 +881,8 @@ confirm_disk_overwrite() {
} }
# Decide what and how to install: sets install_target (full_disk|free_space), # Decide what and how to install: sets install_target (full_disk|free_space),
# install_target and encrypt_installation. Nothing is written to disk yet — # oem_install, and encrypt_installation. Nothing is written to disk yet — the
# the user step runs between this and the execution below. (deferred provisioning never # user step (skipped for OEM) runs between this and the execution below.
# reaches here; it's armed by Ctrl+C on the first screen and goes straight to
# disk selection.)
select_installation() { select_installation() {
local full_disk_only local full_disk_only
@@ -944,9 +893,9 @@ select_installation() {
full_disk_only=false full_disk_only=false
fi fi
# With no free-space option to offer, a full-disk install is the only # A blank disk with no OEM choice to offer has exactly one viable mode;
# mode, so skip the picker and go straight to the overwrite confirm. # skip the picker like the pre-OEM flow did.
if $full_disk_only; then if $full_disk_only && ! oem_supported; then
install_mode="Full disk install" install_mode="Full disk install"
else else
install_mode_form install_mode_form
@@ -954,15 +903,27 @@ select_installation() {
case "$install_mode" in case "$install_mode" in
"Full disk install") "Full disk install")
oem_install=false
if confirm_disk_overwrite; then if confirm_disk_overwrite; then
install_target="full_disk" install_target="full_disk"
return 0 return 0
fi fi
# When the picker was skipped, declining the overwrite means the user # When the picker was skipped there is no menu to fall back to;
# wants a different disk. # declining the overwrite means picking another disk, as before.
$full_disk_only && disk_form if $full_disk_only && ! oem_supported; then
disk_form
fi
;;
"OEM install"*)
oem_install=true
if confirm_disk_overwrite; then
install_target="full_disk"
return 0
fi
oem_install=false
;; ;;
"Free space install"*) "Free space install"*)
oem_install=false
if run_partition_decide; then if run_partition_decide; then
install_target="free_space" install_target="free_space"
return 0 return 0
@@ -975,49 +936,33 @@ select_installation() {
done done
} }
# STEP 1: KEYBOARD (Ctrl+C here arms deferred provisioning and jumps to disk selection) # STEP 3: WHERE AND HOW TO INSTALL
defer_provisioning=false oem_install=false
install_target="full_disk" install_target="full_disk"
# Let the live VT reach its settled width before the first screen so the logo disk_form
# isn't measured against the transient 80-column boot console. select_installation
wait_for_stable_terminal
greeter # STEP 3: KEYBOARD + USER (OEM defers both to the machine's first boot)
keyboard_form true if $oem_install; then
# A defined default keymap so the system boots before first-boot setup; the
if $defer_provisioning; then # owner picks their real layout in the OOBE, which re-keys the console and,
# Deferred provisioning: no user setup, and the keyboard is deferred to the machine's first # on encrypted installs, rebuilds the initramfs so the LUKS prompt matches.
# boot. A defined default keymap so it boots before then; the owner picks
# their real layout in the OOBE, which re-keys the console and, on encrypted
# installs, rebuilds the initramfs so the LUKS prompt matches.
keyboard="us" keyboard="us"
username="" username=""
password="" password=""
password_hash="" password_hash=""
full_name="" full_name=""
email_address="" email_address=""
# Neutral defaults for the install; the owner overwrites both in the
# first-boot OOBE (omarchy-provision-owner).
hostname="omarchy" hostname="omarchy"
timezone="UTC" timezone="UTC"
# Jump straight to disk selection + overwrite confirmation (encrypted by
# default, Ctrl+C toggles unencrypted). deferred provisioning is always a full-disk install.
disk_form
until confirm_disk_overwrite; do
disk_form
done
install_target="full_disk"
else else
# Normal install: keyboard (done above) → user → disk → install mode. The # Keyboard before the user step so the LUKS passphrase is typed under the
# keyboard chosen above is already loaded, so the LUKS passphrase entered in # chosen layout (typing it under the wrong one locks the user out at boot).
# the user step is typed under the right layout. keyboard_form
user_step user_step
disk_form
select_installation
fi fi
clear clear
@@ -1049,9 +994,9 @@ main_partition_size=$((disk_size_in_mib - main_partition_start - gpt_backup_rese
kernel_choice=$(detect_kernel) kernel_choice=$(detect_kernel)
if [[ $encrypt_installation == true ]]; then if [[ $encrypt_installation == true ]]; then
# Deferred-provisioning installs carry no password: the orchestrator generates a throwaway # OEM installs carry no password: the orchestrator generates a throwaway
# LUKS passphrase and stages it for the first-boot re-key. # LUKS passphrase and stages it for the first-boot re-key.
if $defer_provisioning; then if $oem_install; then
encryption_password_line="" encryption_password_line=""
else else
encryption_password_line=", encryption_password_line=",
@@ -1081,7 +1026,7 @@ cat <<-_EOF_ >user_configuration.json
"custom_commands": [], "custom_commands": [],
"omarchy_install": { "omarchy_install": {
"mode": "full_disk", "mode": "full_disk",
"defer_provisioning": $defer_provisioning, "oem": $oem_install,
"target_mount": "/mnt", "target_mount": "/mnt",
"boot": { "boot": {
"esp_mount": "/boot", "esp_mount": "/boot",
@@ -11,8 +11,8 @@
# Anything less than the pair means this isn't an autoinstall drive, and the # Anything less than the pair means this isn't an autoinstall drive, and the
# caller falls back to the wizard. # caller falls back to the wizard.
# #
# A `defer-provisioning` marker file stands in for user_credentials.json: deferred-provisioning # An `oem` marker file stands in for user_credentials.json: OEM installs defer
# installs defer user creation to first boot, so imaging rigs ship no credentials. # user creation to first boot, so imaging rigs ship no credentials at all.
# #
# The optional argument prefixes every path the script touches; tests use it to # The optional argument prefixes every path the script touches; tests use it to
# run against a sandbox instead of the live system. # run against a sandbox instead of the live system.
@@ -39,17 +39,17 @@ mkdir -p "$mnt"
mount -o ro "$device" "$mnt" || exit 1 mount -o ro "$device" "$mnt" || exit 1
# Clear any inputs a previous load in this live session left in /root before # Clear any inputs a previous load in this live session left in /root before
# copying the current drive: a stale `defer-provisioning` marker or credentials file would # copying the current drive: a stale `oem` marker or credentials file would
# otherwise force a fresh drive back into deferred provisioning or hand it an old # otherwise force a fresh drive's config back into OEM mode or hand it an old
# LUKS passphrase. The interactive wizard writes these same names, but a # LUKS passphrase. The interactive wizard writes these same names, but a
# cidata load always precedes it, so nothing of the user's is discarded here. # cidata load always precedes it, so nothing of the user's is discarded here.
optional_inputs=(user_credentials.json defer-provisioning user_full_name.txt user_email_address.txt user_encrypt_installation.txt authorized_keys tailscale_authkey) optional_inputs=(user_credentials.json oem user_full_name.txt user_email_address.txt user_encrypt_installation.txt authorized_keys tailscale_authkey)
for file in user_configuration.json "${optional_inputs[@]}"; do for file in user_configuration.json "${optional_inputs[@]}"; do
rm -f "$dest/$file" rm -f "$dest/$file"
done done
loaded=1 loaded=1
if [[ -f $mnt/user_configuration.json ]] && [[ -f $mnt/user_credentials.json || -f $mnt/defer-provisioning ]]; then if [[ -f $mnt/user_configuration.json ]] && [[ -f $mnt/user_credentials.json || -f $mnt/oem ]]; then
files=("$mnt"/user_configuration.json) files=("$mnt"/user_configuration.json)
for file in "${optional_inputs[@]}"; do for file in "${optional_inputs[@]}"; do
[[ -f $mnt/$file ]] && files+=("$mnt/$file") [[ -f $mnt/$file ]] && files+=("$mnt/$file")
@@ -321,7 +321,7 @@ install_progress() {
"Installing Arch + Omarchy") lo=65 hi=700 tau=150 pkg_signal=1 ;; "Installing Arch + Omarchy") lo=65 hi=700 tau=150 pkg_signal=1 ;;
"Configuring hibernation") lo=700 hi=720 tau=10 ;; "Configuring hibernation") lo=700 hi=720 tau=10 ;;
"Configuring system") lo=720 hi=850 tau=120 ;; "Configuring system") lo=720 hi=850 tau=120 ;;
"Staging provisioning") lo=850 hi=855 tau=5 ;; "Staging OEM state") lo=850 hi=855 tau=5 ;;
"Finalizing Limine boot") lo=855 hi=950 tau=90 ;; "Finalizing Limine boot") lo=855 hi=950 tau=90 ;;
"Finalizing user") lo=950 hi=978 tau=30 ;; "Finalizing user") lo=950 hi=978 tau=30 ;;
"Configuring login") lo=978 hi=988 tau=5 ;; "Configuring login") lo=978 hi=988 tau=5 ;;
@@ -736,17 +736,6 @@ if (( status != 0 )); then
exit "$failure_status" exit "$failure_status"
fi fi
# Deferred-provisioning installs finish silently and reboot on their own — the
# owner completes setup (and sees the send-off) at first boot, so the "Installed
# Omarchy in ..." celebration and the Reboot Now prompt belong to a direct
# install only.
if [[ ${OMARCHY_UI_DEFER_PROVISIONING:-} == "yes" ]]; then
printf '%s' "$CLEAR" >"$TTY_PATH" 2>/dev/null || true
[[ ${OMARCHY_UI_AUTO_REBOOT:-} == "no" ]] && exit 0
reboot 2>/dev/null || systemctl reboot 2>/dev/null || true
exit 0
fi
set +e set +e
render_finish render_finish
finish_render_status=$? finish_render_status=$?
@@ -18,7 +18,7 @@ while [[ $# -gt 0 ]]; do
--encrypt-file) export OMARCHY_INSTALL_ENCRYPT_FILE="$2"; shift 2 ;; --encrypt-file) export OMARCHY_INSTALL_ENCRYPT_FILE="$2"; shift 2 ;;
--authorized-keys-file) export OMARCHY_INSTALL_AUTHORIZED_KEYS_FILE="$2"; shift 2 ;; --authorized-keys-file) export OMARCHY_INSTALL_AUTHORIZED_KEYS_FILE="$2"; shift 2 ;;
--tailscale-authkey-file) export OMARCHY_INSTALL_TAILSCALE_AUTHKEY_FILE="$2"; shift 2 ;; --tailscale-authkey-file) export OMARCHY_INSTALL_TAILSCALE_AUTHKEY_FILE="$2"; shift 2 ;;
--defer-provisioning-file) export OMARCHY_INSTALL_DEFER_PROVISIONING_FILE="$2"; shift 2 ;; --oem-file) export OMARCHY_INSTALL_OEM_FILE="$2"; shift 2 ;;
*) echo "omarchy-iso-install: unknown arg $1" >&2; exit 2 ;; *) echo "omarchy-iso-install: unknown arg $1" >&2; exit 2 ;;
esac esac
done done
@@ -26,7 +26,7 @@ class InstallContext:
user_credentials: dict user_credentials: dict
arch_config_path: Path arch_config_path: Path
omarchy_install: dict[str, Any] omarchy_install: dict[str, Any]
defer_provisioning: bool = False oem: bool = False
target: Path = Path("/mnt") target: Path = Path("/mnt")
omarchy_path: Path = Path("/usr/share/omarchy") omarchy_path: Path = Path("/usr/share/omarchy")
@@ -50,23 +50,23 @@ class InstallContext:
user_configuration = json.loads(config_path.read_text()) user_configuration = json.loads(config_path.read_text())
omarchy_install = user_configuration.get("omarchy_install") or _default_omarchy_install(user_configuration) omarchy_install = user_configuration.get("omarchy_install") or _default_omarchy_install(user_configuration)
# Deferred provisioning: the whole system installs but user creation is deferred to # OEM mode: the whole system installs but user creation is deferred to
# first boot. Selected by the configurator (omarchy_install.defer_provisioning) or by # first boot. Selected by the configurator (omarchy_install.oem) or by
# an `defer-provisioning` marker file on an autoinstall drive, which also replaces the # an `oem` marker file on an autoinstall drive, which also replaces the
# user_credentials.json requirement. # user_credentials.json requirement.
defer_provisioning_marker = _optional_path(os.environ.get("OMARCHY_INSTALL_DEFER_PROVISIONING_FILE")) oem_marker = _optional_path(os.environ.get("OMARCHY_INSTALL_OEM_FILE"))
defer_provisioning = bool(omarchy_install.get("defer_provisioning")) or defer_provisioning_marker is not None oem = bool(omarchy_install.get("oem")) or oem_marker is not None
omarchy_install["defer_provisioning"] = defer_provisioning omarchy_install["oem"] = oem
if creds_path.exists(): if creds_path.exists():
user_credentials = json.loads(creds_path.read_text()) user_credentials = json.loads(creds_path.read_text())
elif defer_provisioning: elif oem:
user_credentials = {"users": []} user_credentials = {"users": []}
else: else:
raise RuntimeError(f"credentials file missing: {creds_path}") raise RuntimeError(f"credentials file missing: {creds_path}")
if defer_provisioning: if oem:
# Deferred provisioning promises no account until first boot. A supplied # OEM promises no account exists until first boot. A supplied
# credentials file (a rig handing over its LUKS passphrase) must # credentials file (a rig handing over its LUKS passphrase) must
# not smuggle in users or a root password. # not smuggle in users or a root password.
encryption_password = user_credentials.get("encryption_password") encryption_password = user_credentials.get("encryption_password")
@@ -77,7 +77,7 @@ class InstallContext:
arch_configuration = dict(user_configuration) arch_configuration = dict(user_configuration)
arch_configuration.pop("omarchy_install", None) arch_configuration.pop("omarchy_install", None)
if defer_provisioning: if oem:
# The userless invariant covers the archinstall config too: a # The userless invariant covers the archinstall config too: a
# combined/legacy config could carry account authentication that # combined/legacy config could carry account authentication that
# archinstall would still act on (users, a root password). Strip # archinstall would still act on (users, a root password). Strip
@@ -87,14 +87,14 @@ class InstallContext:
state_dir = Path(os.environ.get("OMARCHY_INSTALL_STATE_DIR", "/run/omarchy-install")) state_dir = Path(os.environ.get("OMARCHY_INSTALL_STATE_DIR", "/run/omarchy-install"))
state_dir.mkdir(parents=True, exist_ok=True) state_dir.mkdir(parents=True, exist_ok=True)
if defer_provisioning: if oem:
# Encrypted deferred-provisioning installs have no user password to protect LUKS # Encrypted OEM installs have no user password to protect LUKS
# with. Generate a throwaway passphrase (staged for first-boot # with. Generate a throwaway passphrase (staged for first-boot
# re-key by the stage_provisioning_state phase) and hand it to archinstall # re-key by the stage_oem_state phase) and hand it to archinstall
# through both places it may look: the disk_encryption block and # through both places it may look: the disk_encryption block and
# the credentials file. # the credentials file.
_inject_provisioning_encryption_password(arch_configuration, user_credentials) _inject_oem_encryption_password(arch_configuration, user_credentials)
creds_path = state_dir / "provisioning-user_credentials.json" creds_path = state_dir / "oem-user_credentials.json"
creds_path.write_text(json.dumps(user_credentials, indent=2) + "\n") creds_path.write_text(json.dumps(user_credentials, indent=2) + "\n")
creds_path.chmod(0o600) creds_path.chmod(0o600)
@@ -113,7 +113,7 @@ class InstallContext:
user_credentials=user_credentials, user_credentials=user_credentials,
arch_config_path=arch_config_path, arch_config_path=arch_config_path,
omarchy_install=omarchy_install, omarchy_install=omarchy_install,
defer_provisioning=defer_provisioning, oem=oem,
state_dir=state_dir, state_dir=state_dir,
) )
disk_config = user_configuration.get("disk_config", {}) disk_config = user_configuration.get("disk_config", {})
@@ -127,7 +127,7 @@ class InstallContext:
users = self.user_credentials.get("users") or [] users = self.user_credentials.get("users") or []
if users: if users:
return users[0]["username"] return users[0]["username"]
if self.defer_provisioning: if self.oem:
return "" return ""
raise RuntimeError("user_credentials.json contains no users") raise RuntimeError("user_credentials.json contains no users")
@@ -145,7 +145,7 @@ class InstallContext:
def _strip_account_fields(arch_configuration: dict) -> None: def _strip_account_fields(arch_configuration: dict) -> None:
"""Remove every field archinstall reads to create users or set a root """Remove every field archinstall reads to create users or set a root
password, so it cannot ship a hidden provisioning account. password, so an OEM install cannot ship a hidden provisioning account.
Encryption material lives elsewhere (disk_config.disk_encryption) and is Encryption material lives elsewhere (disk_config.disk_encryption) and is
untouched.""" untouched."""
for key in ("!users", "!root-password", "root_enc_password", "users"): for key in ("!users", "!root-password", "root_enc_password", "users"):
@@ -157,12 +157,12 @@ def _strip_account_fields(arch_configuration: dict) -> None:
auth.pop(key, None) auth.pop(key, None)
def _inject_provisioning_encryption_password(arch_configuration: dict, user_credentials: dict) -> None: def _inject_oem_encryption_password(arch_configuration: dict, user_credentials: dict) -> None:
"""Ensure an encrypted deferred-provisioning install has a LUKS passphrase archinstall can """Ensure an encrypted OEM install has a LUKS passphrase archinstall can
use. Reuse one the input already carries (an autoinstall rig may supply use. Reuse one the input already carries (an autoinstall rig may supply
its own); otherwise generate a throwaway. Mutates the disk_encryption its own); otherwise generate a throwaway. Mutates the disk_encryption
block in place — arch_configuration shares it with user_configuration, so block in place — arch_configuration shares it with user_configuration, so
the stage_provisioning_state phase can read the effective passphrase back.""" the stage_oem_state phase can read the effective passphrase back."""
disk_encryption = (arch_configuration.get("disk_config") or {}).get("disk_encryption") disk_encryption = (arch_configuration.get("disk_config") or {}).get("disk_encryption")
if disk_encryption is None: if disk_encryption is None:
return return
@@ -18,9 +18,8 @@ from pathlib import Path
def configure_keyboard(target: Path, language: str) -> bool: def configure_keyboard(target: Path, language: str) -> bool:
"""Write the console keymap into a mounted target without booting it. """Write the console keymap into a mounted target without booting it.
Returns False for layouts localectl doesn't know, matching archinstall: Returns False for layouts localectl doesn't know (the configurator offers
warn and keep the default. Every layout the configurator offers is known; two, ba and khmer), matching archinstall: warn and keep the default.
the guard is for the kb_layout an autoinstall drive can name freely.
""" """
if not language.strip(): if not language.strip():
return True return True
@@ -34,7 +34,7 @@ def build_phases(ctx: InstallContext):
arch_install_system, arch_install_system,
configure_hibernation, configure_hibernation,
run_system_finalizer, run_system_finalizer,
stage_provisioning_state, stage_oem_state,
finalize_limine_boot, finalize_limine_boot,
run_chroot_finalizer, run_chroot_finalizer,
configure_dns_resolver, configure_dns_resolver,
@@ -51,9 +51,9 @@ def build_phases(ctx: InstallContext):
("Installing Arch + Omarchy", arch_install_system), ("Installing Arch + Omarchy", arch_install_system),
("Configuring hibernation", configure_hibernation), ("Configuring hibernation", configure_hibernation),
("Configuring system", run_system_finalizer), ("Configuring system", run_system_finalizer),
# Before finalize_limine_boot: the deferred-provisioning cryptkey drop-in and keyfile # Before finalize_limine_boot: the OEM cryptkey drop-in and keyfile
# must be in place for the final UKI build. # must be in place for the final UKI build.
("Staging provisioning", stage_provisioning_state), ("Staging OEM state", stage_oem_state),
("Finalizing Limine boot", finalize_limine_boot), ("Finalizing Limine boot", finalize_limine_boot),
("Finalizing user", run_chroot_finalizer), ("Finalizing user", run_chroot_finalizer),
("Configuring login", configure_login), ("Configuring login", configure_login),
@@ -72,7 +72,7 @@ def main() -> int:
error(f"Configuration error: {e}") error(f"Configuration error: {e}")
return 2 return 2
who = ctx.username or "deferred provisioning (user created at first boot)" who = ctx.username or "OEM (user created at first boot)"
info(f"Installing Omarchy for {who} → {ctx.target}") info(f"Installing Omarchy for {who} → {ctx.target}")
from .phases_impl import ( from .phases_impl import (
@@ -13,7 +13,7 @@ Phase ordering (full-disk and protected/pre-mounted):
configure_hibernation → root-owned swap/resume drop-ins configure_hibernation → root-owned swap/resume drop-ins
run_system_finalizer → arch-chroot root omarchy-setup-system, including Snapper run_system_finalizer → arch-chroot root omarchy-setup-system, including Snapper
finalize_limine_boot → final Limine config/UKI build after hardware drop-ins finalize_limine_boot → final Limine config/UKI build after hardware drop-ins
run_chroot_finalizer → arch-chroot -u user omarchy-provision-user run_chroot_finalizer → arch-chroot -u user omarchy-finalize-user
configure_login → sddm state + encrypted-install autologin configure_login → sddm state + encrypted-install autologin
configure_ssh_access → authorized_keys for autoinstall; no-op otherwise configure_ssh_access → authorized_keys for autoinstall; no-op otherwise
configure_tailscale → tailnet join staged for first boot; no-op otherwise configure_tailscale → tailnet join staged for first boot; no-op otherwise
@@ -1006,7 +1006,7 @@ def _debug_run(ctx: InstallContext, cmd: list[str]) -> None:
# 2. bind-mount the offline mirror + /opt/packages into /mnt for target pacman # 2. bind-mount the offline mirror + /opt/packages into /mnt for target pacman
# and bundled language runtimes # and bundled language runtimes
# 3. arch-chroot as root → omarchy-setup-system --first-install # 3. arch-chroot as root → omarchy-setup-system --first-install
# 4. arch-chroot as user → omarchy-provision-user --first-install # 4. arch-chroot as user → omarchy-finalize-user --first-install
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
def _prepare_target_setup(ctx: InstallContext) -> None: def _prepare_target_setup(ctx: InstallContext) -> None:
@@ -1136,8 +1136,8 @@ def _run_target_setup_command(ctx: InstallContext, cmd: list[str], *, user: str
def run_system_finalizer(ctx: InstallContext) -> None: def run_system_finalizer(ctx: InstallContext) -> None:
if ctx.defer_provisioning: if ctx.oem:
cmd = ["/usr/bin/omarchy-setup-system", "--defer-provisioning", "--first-install"] cmd = ["/usr/bin/omarchy-setup-system", "--oem", "--first-install"]
else: else:
cmd = ["/usr/bin/omarchy-setup-system", "--install-user", ctx.username, "--first-install"] cmd = ["/usr/bin/omarchy-setup-system", "--install-user", ctx.username, "--first-install"]
@@ -1149,66 +1149,66 @@ def run_system_finalizer(ctx: InstallContext) -> None:
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
# stage_provisioning_state: produce the on-disk "provisioning state" the runtime's first-boot # stage_oem_state: produce the on-disk "OEM state" the runtime's first-boot
# setup (omarchy-provision-owner) and factory reset (omarchy-system-factory-reset) consume. # setup (omarchy-oem-setup) and factory reset (omarchy-system-factory-reset) consume.
# #
# Every install stashes the bundled Node tarball in /var/lib/omarchy/provisioning/ # Every install stashes the bundled Node tarball in /var/lib/omarchy/oem/
# so a later factory reset can finalize the new owner's user offline. deferred-provisioning # so a later factory reset can finalize the new owner's user offline. OEM-mode
# installs additionally arm the first-boot setup service and, on encrypted # installs additionally arm the first-boot setup service and, on encrypted
# targets, stage the throwaway LUKS passphrase: the keyfile embedded in the # targets, stage the throwaway LUKS passphrase: the keyfile embedded in the
# initramfs auto-unlocks boot during the provisioning window, and first-boot setup # initramfs auto-unlocks boot during the OEM window, and first-boot setup
# re-keys the volume to the owner's password and removes it. # re-keys the volume to the owner's password and removes it.
# #
# Runs before finalize_limine_boot so the cryptkey cmdline drop-in and the # Runs before finalize_limine_boot so the cryptkey cmdline drop-in and the
# keyfile land in the final UKI build. # keyfile land in the final UKI build.
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
PROVISION_STATE_DIR = "var/lib/omarchy/provisioning" OEM_STATE_DIR = "var/lib/omarchy/oem"
PROVISION_KEYFILE = "etc/omarchy/provisioning.key" OEM_KEYFILE = "etc/omarchy/oem.key"
NODE_PACKAGES_DIR = Path("/opt/packages") NODE_PACKAGES_DIR = Path("/opt/packages")
def stage_provisioning_state(ctx: InstallContext) -> None: def stage_oem_state(ctx: InstallContext) -> None:
# World-readable: first-boot finalization reads the Node tarball as the # World-readable: first-boot finalization reads the Node tarball as the
# new user. The only secret inside (luks-key) is itself 0600 root. # new user. The only secret inside (luks-key) is itself 0600 root.
provisioning_dir = ctx.target / PROVISION_STATE_DIR oem_dir = ctx.target / OEM_STATE_DIR
provisioning_dir.mkdir(parents=True, exist_ok=True) oem_dir.mkdir(parents=True, exist_ok=True)
provisioning_dir.chmod(0o755) oem_dir.chmod(0o755)
_stage_node_tarball(ctx, provisioning_dir) _stage_node_tarball(ctx, oem_dir)
if not ctx.defer_provisioning: if not ctx.oem:
return return
service_src = ctx.target / "usr/share/omarchy/install/provisioning/omarchy-provision-owner.service" service_src = ctx.target / "usr/share/omarchy/install/oem/omarchy-oem-setup.service"
setup_bin = ctx.target / "usr/bin/omarchy-provision-owner" setup_bin = ctx.target / "usr/bin/omarchy-oem-setup"
if not service_src.exists() or not setup_bin.exists(): if not service_src.exists() or not setup_bin.exists():
raise RuntimeError( raise RuntimeError(
"deferred-provisioning install requested, but the installed Omarchy runtime does not ship " "OEM install requested, but the installed Omarchy runtime does not ship "
"first-boot setup (omarchy-provision-owner + install/provisioning/omarchy-provision-owner.service). " "first-boot setup (omarchy-oem-setup + install/oem/omarchy-oem-setup.service). "
"Update the runtime package this ISO bundles before installing in deferred provisioning." "Update the runtime package this ISO bundles before installing in OEM mode."
) )
info("› arming first-boot setup") info("› arming first-boot OEM setup")
(provisioning_dir / "pending").touch() (oem_dir / "pending").touch()
unit_dst = ctx.target / "etc/systemd/system/omarchy-provision-owner.service" unit_dst = ctx.target / "etc/systemd/system/omarchy-oem-setup.service"
unit_dst.parent.mkdir(parents=True, exist_ok=True) unit_dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(service_src, unit_dst) shutil.copy2(service_src, unit_dst)
wants_dir = ctx.target / "etc/systemd/system/multi-user.target.wants" wants_dir = ctx.target / "etc/systemd/system/multi-user.target.wants"
wants_dir.mkdir(parents=True, exist_ok=True) wants_dir.mkdir(parents=True, exist_ok=True)
link = wants_dir / "omarchy-provision-owner.service" link = wants_dir / "omarchy-oem-setup.service"
link.unlink(missing_ok=True) link.unlink(missing_ok=True)
link.symlink_to("/etc/systemd/system/omarchy-provision-owner.service") link.symlink_to("/etc/systemd/system/omarchy-oem-setup.service")
if _provision_install_encrypted(ctx): if _oem_install_encrypted(ctx):
_stage_provisioning_luks_unlock(ctx, provisioning_dir) _stage_oem_luks_unlock(ctx, oem_dir)
def _stage_node_tarball(ctx: InstallContext, provisioning_dir) -> None: def _stage_node_tarball(ctx: InstallContext, oem_dir) -> None:
tarballs = sorted(NODE_PACKAGES_DIR.glob("node-v*-linux-x64.tar.gz")) tarballs = sorted(NODE_PACKAGES_DIR.glob("node-v*-linux-x64.tar.gz"))
if not tarballs: if not tarballs:
# Hard error on every install, not just deferred-provisioning installs: the stash is what lets a # Hard error on every install, not just OEM: the stash is what lets a
# later factory reset finalize the next owner offline, and an ISO # later factory reset finalize the next owner offline, and an ISO
# build always bundles the tarball — its absence means a broken build. # build always bundles the tarball — its absence means a broken build.
raise RuntimeError( raise RuntimeError(
@@ -1216,7 +1216,7 @@ def _stage_node_tarball(ctx: InstallContext, provisioning_dir) -> None:
"and factory reset could not finalize a user offline" "and factory reset could not finalize a user offline"
) )
packages_dir = provisioning_dir / "packages" packages_dir = oem_dir / "packages"
packages_dir.mkdir(parents=True, exist_ok=True) packages_dir.mkdir(parents=True, exist_ok=True)
target_tarball = packages_dir / tarballs[0].name target_tarball = packages_dir / tarballs[0].name
if not target_tarball.exists(): if not target_tarball.exists():
@@ -1224,7 +1224,7 @@ def _stage_node_tarball(ctx: InstallContext, provisioning_dir) -> None:
shutil.copy2(tarballs[0], target_tarball) shutil.copy2(tarballs[0], target_tarball)
def _provision_install_encrypted(ctx: InstallContext) -> bool: def _oem_install_encrypted(ctx: InstallContext) -> bool:
if _storage_intent(ctx).get("luks_uuid"): if _storage_intent(ctx).get("luks_uuid"):
return True return True
disk_encryption = (ctx.user_configuration.get("disk_config") or {}).get("disk_encryption") disk_encryption = (ctx.user_configuration.get("disk_config") or {}).get("disk_encryption")
@@ -1233,43 +1233,43 @@ def _provision_install_encrypted(ctx: InstallContext) -> bool:
return ctx.encrypt return ctx.encrypt
def _provision_encryption_password(ctx: InstallContext) -> str | None: def _oem_encryption_password(ctx: InstallContext) -> str | None:
disk_encryption = (ctx.user_configuration.get("disk_config") or {}).get("disk_encryption") or {} disk_encryption = (ctx.user_configuration.get("disk_config") or {}).get("disk_encryption") or {}
return disk_encryption.get("encryption_password") or ctx.user_credentials.get("encryption_password") return disk_encryption.get("encryption_password") or ctx.user_credentials.get("encryption_password")
def _stage_provisioning_luks_unlock(ctx: InstallContext, provisioning_dir) -> None: def _stage_oem_luks_unlock(ctx: InstallContext, oem_dir) -> None:
password = _provision_encryption_password(ctx) password = _oem_encryption_password(ctx)
if not password: if not password:
# Full-disk deferred-provisioning installs get a generated passphrase injected by # Full-disk OEM installs get a generated passphrase injected by
# InstallContext; only a pre-mounted (rig-partitioned) LUKS target can # InstallContext; only a pre-mounted (rig-partitioned) LUKS target can
# land here, and it must hand over the passphrase it formatted with. # land here, and it must hand over the passphrase it formatted with.
raise RuntimeError( raise RuntimeError(
"deferred-provisioning install on a pre-encrypted target requires the LUKS passphrase " "OEM install on a pre-encrypted target requires the LUKS passphrase "
"in user_credentials.json (encryption_password) so first boot can re-key" "in user_credentials.json (encryption_password) so first boot can re-key"
) )
info("› staging LUKS auto-unlock for the provisioning window") info("› staging LUKS auto-unlock for the OEM window")
# Byte-for-byte the slot passphrase: no trailing newline anywhere. # Byte-for-byte the slot passphrase: no trailing newline anywhere.
luks_key = provisioning_dir / "luks-key" luks_key = oem_dir / "luks-key"
luks_key.write_text(password) luks_key.write_text(password)
luks_key.chmod(0o600) luks_key.chmod(0o600)
keyfile = ctx.target / PROVISION_KEYFILE keyfile = ctx.target / OEM_KEYFILE
keyfile.parent.mkdir(parents=True, exist_ok=True) keyfile.parent.mkdir(parents=True, exist_ok=True)
keyfile.write_text(password) keyfile.write_text(password)
keyfile.chmod(0o600) keyfile.chmod(0o600)
cmdline_dropin = ctx.target / "etc/limine-entry-tool.d/99-omarchy-provisioning-unlock.conf" cmdline_dropin = ctx.target / "etc/limine-entry-tool.d/99-omarchy-oem-unlock.conf"
cmdline_dropin.parent.mkdir(parents=True, exist_ok=True) cmdline_dropin.parent.mkdir(parents=True, exist_ok=True)
cmdline_dropin.write_text( cmdline_dropin.write_text(
'KERNEL_CMDLINE[default]+=" cryptkey=rootfs:/etc/omarchy/provisioning.key"\n' 'KERNEL_CMDLINE[default]+=" cryptkey=rootfs:/etc/omarchy/oem.key"\n'
) )
files_dropin = ctx.target / "etc/mkinitcpio.conf.d/99-omarchy-provisioning-key.conf" files_dropin = ctx.target / "etc/mkinitcpio.conf.d/99-omarchy-oem-key.conf"
files_dropin.parent.mkdir(parents=True, exist_ok=True) files_dropin.parent.mkdir(parents=True, exist_ok=True)
files_dropin.write_text("FILES+=(/etc/omarchy/provisioning.key)\n") files_dropin.write_text("FILES+=(/etc/omarchy/oem.key)\n")
def finalize_limine_boot(ctx: InstallContext) -> None: def finalize_limine_boot(ctx: InstallContext) -> None:
@@ -1365,13 +1365,13 @@ def _limine_kernel_cmdline(config_text: str) -> str:
def run_chroot_finalizer(ctx: InstallContext) -> None: def run_chroot_finalizer(ctx: InstallContext) -> None:
if ctx.defer_provisioning: if ctx.oem:
info("› deferred-provisioning install: user finalization deferred to first boot") info("› OEM install: user finalization deferred to first boot")
return return
_run_target_setup_command( _run_target_setup_command(
ctx, ctx,
["/usr/bin/omarchy-provision-user", "--force", "--first-install"], ["/usr/bin/omarchy-finalize-user", "--force", "--first-install"],
user=ctx.username, user=ctx.username,
) )
@@ -1415,18 +1415,18 @@ def configure_login(ctx: InstallContext) -> None:
) )
autologin_conf = sddm_dir / "autologin.conf" autologin_conf = sddm_dir / "autologin.conf"
if ctx.encrypt and not ctx.defer_provisioning: if ctx.encrypt and not ctx.oem:
autologin_conf.write_text( autologin_conf.write_text(
"[Autologin]\n" "[Autologin]\n"
f"User={ctx.username}\n" f"User={ctx.username}\n"
"Session=omarchy.desktop\n" "Session=omarchy.desktop\n"
) )
else: else:
# deferred-provisioning installs have no user yet; omarchy-provision-owner writes autologin # OEM installs have no user yet; omarchy-oem-setup writes autologin
# and SDDM state at first boot once the owner exists. # and SDDM state at first boot once the owner exists.
autologin_conf.unlink(missing_ok=True) autologin_conf.unlink(missing_ok=True)
if not ctx.defer_provisioning: if not ctx.oem:
state_dir = ctx.target / "var" / "lib" / "sddm" state_dir = ctx.target / "var" / "lib" / "sddm"
state_dir.mkdir(parents=True, exist_ok=True) state_dir.mkdir(parents=True, exist_ok=True)
(state_dir / "state.conf").write_text( (state_dir / "state.conf").write_text(
@@ -1460,14 +1460,14 @@ def configure_ssh_access(ctx: InstallContext) -> None:
keys = _authorized_keys(ctx.authorized_keys_path) keys = _authorized_keys(ctx.authorized_keys_path)
if ctx.defer_provisioning: if ctx.oem:
# No user to authorize yet. Stage the keys in provisioning state for # No user to authorize yet. Stage the keys in OEM state for
# omarchy-provision-owner to install once first boot creates the owner, and # omarchy-oem-setup to install once first boot creates the owner, and
# still open the door (sshd + ufw) below. # still open the door (sshd + ufw) below.
info(f"› staging {len(keys)} SSH key(s) for the first-boot user") info(f"› staging {len(keys)} SSH key(s) for the first-boot user")
provisioning_dir = ctx.target / PROVISION_STATE_DIR oem_dir = ctx.target / OEM_STATE_DIR
provisioning_dir.mkdir(parents=True, exist_ok=True) oem_dir.mkdir(parents=True, exist_ok=True)
staged = provisioning_dir / "authorized_keys" staged = oem_dir / "authorized_keys"
staged.write_text("".join(f"{key}\n" for key in keys)) staged.write_text("".join(f"{key}\n" for key in keys))
staged.chmod(0o600) staged.chmod(0o600)
else: else:
@@ -1695,33 +1695,33 @@ def validate_boot(ctx: InstallContext) -> None:
if ctx.is_protected: if ctx.is_protected:
_validate_pre_mounted_filesystems(ctx) _validate_pre_mounted_filesystems(ctx)
if ctx.defer_provisioning: if ctx.oem:
_validate_provisioning_state(ctx) _validate_oem_state(ctx)
def _validate_provisioning_state(ctx: InstallContext) -> None: def _validate_oem_state(ctx: InstallContext) -> None:
"""An deferred-provisioning install that boots without a working first-boot setup is a """An OEM install that boots without a working first-boot setup is a
user-less brick; insist the armed state is complete before reboot.""" user-less brick; insist the armed state is complete before reboot."""
provisioning_dir = ctx.target / PROVISION_STATE_DIR oem_dir = ctx.target / OEM_STATE_DIR
if not (provisioning_dir / "pending").exists(): if not (oem_dir / "pending").exists():
raise RuntimeError(f"deferred-provisioning install but {provisioning_dir / 'pending'} is missing") raise RuntimeError(f"OEM install but {oem_dir / 'pending'} is missing")
link = ctx.target / "etc/systemd/system/multi-user.target.wants/omarchy-provision-owner.service" link = ctx.target / "etc/systemd/system/multi-user.target.wants/omarchy-oem-setup.service"
if not link.is_symlink(): if not link.is_symlink():
raise RuntimeError("deferred-provisioning install but omarchy-provision-owner.service is not enabled") raise RuntimeError("OEM install but omarchy-oem-setup.service is not enabled")
if not list((provisioning_dir / "packages").glob("node-v*.tar.gz")): if not list((oem_dir / "packages").glob("node-v*.tar.gz")):
raise RuntimeError(f"deferred-provisioning install but no Node tarball staged in {provisioning_dir / 'packages'}") raise RuntimeError(f"OEM install but no Node tarball staged in {oem_dir / 'packages'}")
if _provision_install_encrypted(ctx): if _oem_install_encrypted(ctx):
for required in (provisioning_dir / "luks-key", ctx.target / PROVISION_KEYFILE): for required in (oem_dir / "luks-key", ctx.target / OEM_KEYFILE):
if not required.exists(): if not required.exists():
raise RuntimeError(f"encrypted deferred-provisioning install but {required} is missing") raise RuntimeError(f"encrypted OEM install but {required} is missing")
limine_conf_text = ( limine_conf_text = (
ctx.target / _boot_intent(ctx)["esp_mount"].lstrip("/") / "limine.conf" ctx.target / _boot_intent(ctx)["esp_mount"].lstrip("/") / "limine.conf"
).read_text() ).read_text()
if "cryptkey=rootfs:" not in limine_conf_text: if "cryptkey=rootfs:" not in limine_conf_text:
raise RuntimeError("encrypted deferred-provisioning install but limine.conf has no cryptkey= for auto-unlock") raise RuntimeError("encrypted OEM install but limine.conf has no cryptkey= for auto-unlock")
def _assert_boot_hooks_restored(ctx: InstallContext) -> None: def _assert_boot_hooks_restored(ctx: InstallContext) -> None:
@@ -1835,15 +1835,15 @@ def create_factory_snapshot(ctx: InstallContext) -> None:
# Provisioning credentials staged for THIS deployment's first boot must not # Provisioning credentials staged for THIS deployment's first boot must not
# survive into the factory image: a reset years later would otherwise hand the # survive into the factory image: a reset years later would otherwise hand the
# next owner the original deployment's SSH keys or rejoin its tailnet, and a # next owner the original deployment's SSH keys or rejoin its tailnet, and a
# stale LUKS key (dead after the first re-key) has no business lingering. # stale OEM LUKS key (dead after the first re-key) has no business lingering.
# The mkinitcpio/cmdline drop-ins go with the keyfile — a reset rebuild would # The mkinitcpio/cmdline drop-ins go with the keyfile — a reset rebuild would
# otherwise fail on FILES pointing at a scrubbed path. # otherwise fail on FILES pointing at a scrubbed path.
FACTORY_SCRUB_PATHS = ( FACTORY_SCRUB_PATHS = (
"var/lib/omarchy/provisioning/authorized_keys", "var/lib/omarchy/oem/authorized_keys",
"var/lib/omarchy/provisioning/luks-key", "var/lib/omarchy/oem/luks-key",
"etc/omarchy/provisioning.key", "etc/omarchy/oem.key",
"etc/limine-entry-tool.d/99-omarchy-provisioning-unlock.conf", "etc/limine-entry-tool.d/99-omarchy-oem-unlock.conf",
"etc/mkinitcpio.conf.d/99-omarchy-provisioning-key.conf", "etc/mkinitcpio.conf.d/99-omarchy-oem-key.conf",
"etc/tailscale/authkey", "etc/tailscale/authkey",
"etc/systemd/system/omarchy-tailscale-join.service", "etc/systemd/system/omarchy-tailscale-join.service",
"etc/systemd/system/multi-user.target.wants/omarchy-tailscale-join.service", "etc/systemd/system/multi-user.target.wants/omarchy-tailscale-join.service",
+24 -24
View File
@@ -124,56 +124,56 @@ run_load || fail "required pair plus authorized_keys loads"
[[ ! -e $sandbox/root/tailscale_authkey ]] || fail "absent tailscale_authkey is not copied" [[ ! -e $sandbox/root/tailscale_authkey ]] || fail "absent tailscale_authkey is not copied"
pass "present optional files are copied, absent ones skipped" pass "present optional files are copied, absent ones skipped"
# A defer-provisioning marker replaces user_credentials.json: deferred-provisioning installs # An oem marker replaces user_credentials.json: OEM installs defer user
# creation to first boot, so imaging rigs ship no credentials at all. # creation to first boot, so imaging rigs ship no credentials at all.
new_sandbox new_sandbox
attach_drive cidata attach_drive cidata
echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json" echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json"
: >"$sandbox/media/defer-provisioning" : >"$sandbox/media/oem"
run_load || fail "config plus defer-provisioning marker loads" run_load || fail "config plus oem marker loads"
[[ -f $sandbox/root/defer-provisioning ]] || fail "defer-provisioning marker is copied" [[ -f $sandbox/root/oem ]] || fail "oem marker is copied"
[[ ! -e $sandbox/root/user_credentials.json ]] || fail "defer-provisioning drive copies no credentials" [[ ! -e $sandbox/root/user_credentials.json ]] || fail "oem drive copies no credentials"
pass "defer-provisioning marker stands in for credentials" pass "oem marker stands in for credentials"
# The defer-provisioning marker and credentials can coexist (rig supplies its own LUKS # The oem marker and credentials can coexist (rig supplies its own LUKS
# passphrase in the credentials file); both are copied. # passphrase in the credentials file); both are copied.
new_sandbox new_sandbox
attach_drive cidata attach_drive cidata
write_required_pair write_required_pair
: >"$sandbox/media/defer-provisioning" : >"$sandbox/media/oem"
run_load || fail "defer-provisioning marker plus credentials loads" run_load || fail "oem marker plus credentials loads"
[[ -f $sandbox/root/defer-provisioning && -f $sandbox/root/user_credentials.json ]] || fail "both defer-provisioning marker and credentials are copied" [[ -f $sandbox/root/oem && -f $sandbox/root/user_credentials.json ]] || fail "both oem marker and credentials are copied"
pass "defer-provisioning marker plus credentials copies both" pass "oem marker plus credentials copies both"
# An defer-provisioning marker without the configuration is still not an autoinstall drive. # An oem marker without the configuration is still not an autoinstall drive.
new_sandbox new_sandbox
attach_drive cidata attach_drive cidata
: >"$sandbox/media/defer-provisioning" : >"$sandbox/media/oem"
! run_load || fail "defer-provisioning marker alone is not an autoinstall drive" ! run_load || fail "oem marker alone is not an autoinstall drive"
[[ ! -e $sandbox/root/defer-provisioning ]] || fail "defer-provisioning marker alone copies nothing" [[ ! -e $sandbox/root/oem ]] || fail "oem marker alone copies nothing"
pass "defer-provisioning marker alone falls back to the wizard" pass "oem marker alone falls back to the wizard"
# Stale deferred-provisioning inputs from a previous load in the same session are cleared before # Stale OEM inputs from a previous load in the same session are cleared before
# the current drive is copied: a normal drive must not inherit an old defer-provisioning # the current drive is copied: a normal drive must not inherit an old oem
# marker or credentials. # marker or credentials.
new_sandbox new_sandbox
attach_drive cidata attach_drive cidata
write_required_pair write_required_pair
: >"$sandbox/root/defer-provisioning" # leftover from a prior deferred-provisioning load : >"$sandbox/root/oem" # leftover from a prior OEM load
echo 'old-keys' >"$sandbox/root/authorized_keys" echo 'old-keys' >"$sandbox/root/authorized_keys"
run_load || fail "normal drive after a stale defer-provisioning load loads" run_load || fail "normal drive after a stale OEM load loads"
[[ ! -e $sandbox/root/defer-provisioning ]] || fail "stale defer-provisioning marker is cleared" [[ ! -e $sandbox/root/oem ]] || fail "stale oem marker is cleared"
[[ ! -e $sandbox/root/authorized_keys ]] || fail "stale optional inputs are cleared" [[ ! -e $sandbox/root/authorized_keys ]] || fail "stale optional inputs are cleared"
pass "stale deferred-provisioning inputs are cleared before loading a normal drive" pass "stale OEM inputs are cleared before loading a normal drive"
# A drive that isn't an autoinstall drive at all still clears stale inputs so # A drive that isn't an autoinstall drive at all still clears stale inputs so
# the wizard that follows doesn't inherit them. # the wizard that follows doesn't inherit them.
new_sandbox new_sandbox
attach_drive cidata attach_drive cidata
echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json" # half a pair echo '{"disk_config": {}}' >"$sandbox/media/user_configuration.json" # half a pair
: >"$sandbox/root/defer-provisioning" : >"$sandbox/root/oem"
! run_load || fail "half-pair drive still falls back" ! run_load || fail "half-pair drive still falls back"
[[ ! -e $sandbox/root/defer-provisioning ]] || fail "stale defer-provisioning marker cleared even on fallback" [[ ! -e $sandbox/root/oem ]] || fail "stale oem marker cleared even on fallback"
pass "stale inputs are cleared even when falling back to the wizard" pass "stale inputs are cleared even when falling back to the wizard"
# Half the required pair is not an autoinstall drive: unmount and fall back. # Half the required pair is not an autoinstall drive: unmount and fall back.
+1 -1
View File
@@ -60,7 +60,7 @@ class ConfigureSshAccessTest(unittest.TestCase):
if authorized_keys is not None: if authorized_keys is not None:
authorized_keys_path = self.target / "authorized_keys" authorized_keys_path = self.target / "authorized_keys"
authorized_keys_path.write_text(authorized_keys) authorized_keys_path.write_text(authorized_keys)
return types.SimpleNamespace(target=self.target, username="jeff", authorized_keys_path=authorized_keys_path, defer_provisioning=False) return types.SimpleNamespace(target=self.target, username="jeff", authorized_keys_path=authorized_keys_path, oem=False)
def configure(self, **kwargs): def configure(self, **kwargs):
phases_impl.configure_ssh_access(self.ctx(**kwargs)) phases_impl.configure_ssh_access(self.ctx(**kwargs))
+11 -27
View File
@@ -14,30 +14,14 @@ KEYBOARD = importlib.util.module_from_spec(SPEC)
assert SPEC.loader assert SPEC.loader
SPEC.loader.exec_module(KEYBOARD) SPEC.loader.exec_module(KEYBOARD)
# The layout list lives in the Omarchy runtime now, shared verbatim with the CONFIGURATOR = (ROOT / "configs/airootfs/root/configurator").read_text()
# first-boot owner setup; build-iso.sh vendors it onto the ISO. Read it from KEYBOARD_BLOCK = re.search(r"keyboards=\$'(.*?)'\n choice=", CONFIGURATOR, re.DOTALL)
# wherever this checkout can see a runtime, and skip the coverage test rather assert KEYBOARD_BLOCK
# than fail when none is around (a bare CI checkout of just this repo). SUPPORTED_KEYMAPS = [
SETUP_FORM_CANDIDATES = ( line.split("|", 1)[1]
Path("/omarchy-source/install/provisioning/setup-form.sh"), for line in KEYBOARD_BLOCK.group(1).splitlines()
ROOT.parent / "omarchy/install/provisioning/setup-form.sh", ]
Path("/usr/share/omarchy/install/provisioning/setup-form.sh"), UNSUPPORTED_KEYMAPS = {"ba", "khmer"}
)
def supported_keymaps():
for candidate in SETUP_FORM_CANDIDATES:
if not candidate.is_file():
continue
block = re.search(
r"OMARCHY_KEYBOARD_LAYOUTS=\$'(.*?)'\n", candidate.read_text(), re.DOTALL
)
assert block, f"no layout list in {candidate}"
return [line.split("|", 1)[1] for line in block.group(1).splitlines()]
return None
SUPPORTED_KEYMAPS = supported_keymaps()
class KeyboardConfigurationTest(unittest.TestCase): class KeyboardConfigurationTest(unittest.TestCase):
@@ -61,12 +45,12 @@ class KeyboardConfigurationTest(unittest.TestCase):
self.assertEqual(lines.count("FONT=default8x16"), 1) self.assertEqual(lines.count("FONT=default8x16"), 1)
def test_all_configurator_keymaps_are_known_to_localectl(self): def test_all_configurator_keymaps_are_known_to_localectl(self):
if SUPPORTED_KEYMAPS is None:
self.skipTest("no Omarchy runtime checkout to read the layout list from")
for keymap in SUPPORTED_KEYMAPS: for keymap in SUPPORTED_KEYMAPS:
with self.subTest(keymap=keymap), tempfile.TemporaryDirectory() as directory: with self.subTest(keymap=keymap), tempfile.TemporaryDirectory() as directory:
target = self.target(directory) target = self.target(directory)
self.assertTrue(KEYBOARD.configure_keyboard(target, keymap)) configured = KEYBOARD.configure_keyboard(target, keymap)
self.assertEqual(configured, keymap not in UNSUPPORTED_KEYMAPS)
if configured:
lines = (target / "etc/vconsole.conf").read_text().splitlines() lines = (target / "etc/vconsole.conf").read_text().splitlines()
self.assertIn(f"KEYMAP={keymap}", lines) self.assertIn(f"KEYMAP={keymap}", lines)
self.assertEqual(lines.count("FONT=default8x16"), 1) self.assertEqual(lines.count("FONT=default8x16"), 1)
@@ -1,7 +1,7 @@
"""Unit tests for deferred-provisioning install support in the orchestrator. """Unit tests for OEM install support in the orchestrator.
Covers the InstallContext deferred-provisioning plumbing (marker file, credential-less input, Covers the InstallContext OEM plumbing (marker file, credential-less input,
throwaway LUKS passphrase injection) and the stage_provisioning_state / throwaway LUKS passphrase injection) and the stage_oem_state /
create_factory_snapshot / configure_login phases against a temp target with create_factory_snapshot / configure_login phases against a temp target with
subprocess mocked out. subprocess mocked out.
""" """
@@ -26,7 +26,7 @@ from orchestrator import phases_impl # noqa: E402
from orchestrator.context import InstallContext # noqa: E402 from orchestrator.context import InstallContext # noqa: E402
class ContextDeferProvisioningTest(unittest.TestCase): class ContextOemTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.tmp = tempfile.TemporaryDirectory() self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup) self.addCleanup(self.tmp.cleanup)
@@ -48,51 +48,51 @@ class ContextDeferProvisioningTest(unittest.TestCase):
def from_env(self, **extra_env): def from_env(self, **extra_env):
env = {**self.env, **extra_env} env = {**self.env, **extra_env}
with mock.patch.dict(os.environ, env, clear=False): with mock.patch.dict(os.environ, env, clear=False):
for key in ("OMARCHY_INSTALL_DEFER_PROVISIONING_FILE",): for key in ("OMARCHY_INSTALL_OEM_FILE",):
if key not in env: if key not in env:
os.environ.pop(key, None) os.environ.pop(key, None)
return InstallContext.from_env() return InstallContext.from_env()
def base_config(self, defer_provisioning=None, disk_encryption=None): def base_config(self, oem=None, disk_encryption=None):
config = { config = {
"disk_config": {"config_type": "default_layout"}, "disk_config": {"config_type": "default_layout"},
"omarchy_install": {"mode": "full_disk", "target_mount": "/mnt"}, "omarchy_install": {"mode": "full_disk", "target_mount": "/mnt"},
} }
if defer_provisioning is not None: if oem is not None:
config["omarchy_install"]["defer_provisioning"] = defer_provisioning config["omarchy_install"]["oem"] = oem
if disk_encryption is not None: if disk_encryption is not None:
config["disk_config"]["disk_encryption"] = disk_encryption config["disk_config"]["disk_encryption"] = disk_encryption
return config return config
def test_defer_provisioning_flag_from_config(self): def test_oem_flag_from_config(self):
self.write_config(self.base_config(defer_provisioning=True)) self.write_config(self.base_config(oem=True))
ctx = self.from_env() ctx = self.from_env()
self.assertTrue(ctx.defer_provisioning) self.assertTrue(ctx.oem)
self.assertEqual(ctx.user_credentials, {"users": []}) self.assertEqual(ctx.user_credentials, {"users": []})
self.assertEqual(ctx.username, "") self.assertEqual(ctx.username, "")
def test_marker_file_arms_deferred_provisioning_without_credentials(self): def test_oem_marker_file_arms_oem_without_credentials(self):
self.write_config(self.base_config()) self.write_config(self.base_config())
marker = self.dir / "defer_provisioning" marker = self.dir / "oem"
marker.touch() marker.touch()
ctx = self.from_env(OMARCHY_INSTALL_DEFER_PROVISIONING_FILE=str(marker)) ctx = self.from_env(OMARCHY_INSTALL_OEM_FILE=str(marker))
self.assertTrue(ctx.defer_provisioning) self.assertTrue(ctx.oem)
self.assertTrue(ctx.omarchy_install["defer_provisioning"]) self.assertTrue(ctx.omarchy_install["oem"])
def test_absent_marker_file_is_not_deferred_provisioning(self): def test_absent_marker_file_is_not_oem(self):
self.write_config(self.base_config()) self.write_config(self.base_config())
self.write_creds({"users": [{"username": "jeff"}]}) self.write_creds({"users": [{"username": "jeff"}]})
ctx = self.from_env(OMARCHY_INSTALL_DEFER_PROVISIONING_FILE=str(self.dir / "missing-defer_provisioning")) ctx = self.from_env(OMARCHY_INSTALL_OEM_FILE=str(self.dir / "missing-oem"))
self.assertFalse(ctx.defer_provisioning) self.assertFalse(ctx.oem)
self.assertEqual(ctx.username, "jeff") self.assertEqual(ctx.username, "jeff")
def test_missing_credentials_without_defer_provisioning_raises(self): def test_missing_credentials_without_oem_raises(self):
self.write_config(self.base_config()) self.write_config(self.base_config())
with self.assertRaisesRegex(RuntimeError, "credentials file missing"): with self.assertRaisesRegex(RuntimeError, "credentials file missing"):
self.from_env() self.from_env()
def test_deferred_provisioning_generates_throwaway_luks_passphrase(self): def test_oem_generates_throwaway_luks_passphrase(self):
self.write_config(self.base_config(defer_provisioning=True, disk_encryption={ self.write_config(self.base_config(oem=True, disk_encryption={
"encryption_type": "luks", "partitions": ["x"], "encryption_type": "luks", "partitions": ["x"],
})) }))
ctx = self.from_env() ctx = self.from_env()
@@ -110,8 +110,8 @@ class ContextDeferProvisioningTest(unittest.TestCase):
synthesized = json.loads(ctx.creds_path.read_text()) synthesized = json.loads(ctx.creds_path.read_text())
self.assertEqual(synthesized["encryption_password"], password) self.assertEqual(synthesized["encryption_password"], password)
def test_deferred_provisioning_reuses_rig_supplied_passphrase(self): def test_oem_reuses_rig_supplied_passphrase(self):
self.write_config(self.base_config(defer_provisioning=True, disk_encryption={ self.write_config(self.base_config(oem=True, disk_encryption={
"encryption_type": "luks", "partitions": ["x"], "encryption_type": "luks", "partitions": ["x"],
})) }))
self.write_creds({"users": [], "encryption_password": "rig-secret"}) self.write_creds({"users": [], "encryption_password": "rig-secret"})
@@ -121,9 +121,9 @@ class ContextDeferProvisioningTest(unittest.TestCase):
"rig-secret", "rig-secret",
) )
def test_deferred_provisioning_discards_account_material(self): def test_oem_discards_account_material_from_supplied_credentials(self):
# A rig credentials file must not smuggle in users or a root password. # A rig credentials file must not smuggle in users or a root password.
self.write_config(self.base_config(defer_provisioning=True)) self.write_config(self.base_config(oem=True))
self.write_creds({ self.write_creds({
"users": [{"username": "backdoor", "enc_password": "x", "sudo": True}], "users": [{"username": "backdoor", "enc_password": "x", "sudo": True}],
"root_enc_password": "x", "root_enc_password": "x",
@@ -137,8 +137,8 @@ class ContextDeferProvisioningTest(unittest.TestCase):
self.assertEqual(synthesized["users"], []) self.assertEqual(synthesized["users"], [])
self.assertNotIn("root_enc_password", synthesized) self.assertNotIn("root_enc_password", synthesized)
def test_defer_provisioning_strips_account_fields(self): def test_oem_strips_account_fields_from_arch_config(self):
config = self.base_config(defer_provisioning=True) config = self.base_config(oem=True)
config["!users"] = [{"username": "rig"}] config["!users"] = [{"username": "rig"}]
config["!root-password"] = "hunter2" config["!root-password"] = "hunter2"
config["root_enc_password"] = "x" config["root_enc_password"] = "x"
@@ -151,8 +151,8 @@ class ContextDeferProvisioningTest(unittest.TestCase):
self.assertNotIn(key, arch_config) self.assertNotIn(key, arch_config)
self.assertEqual(arch_config["auth_config"], {}) self.assertEqual(arch_config["auth_config"], {})
def test_deferred_provisioning_unencrypted_touches_nothing(self): def test_oem_unencrypted_touches_nothing(self):
self.write_config(self.base_config(defer_provisioning=True)) self.write_config(self.base_config(oem=True))
ctx = self.from_env() ctx = self.from_env()
self.assertNotIn("encryption_password", ctx.user_credentials) self.assertNotIn("encryption_password", ctx.user_credentials)
@@ -160,10 +160,10 @@ class ContextDeferProvisioningTest(unittest.TestCase):
def make_ctx(target, **overrides): def make_ctx(target, **overrides):
defaults = dict( defaults = dict(
target=target, target=target,
defer_provisioning=True, oem=True,
encrypt=False, encrypt=False,
username="", username="",
omarchy_install={"mode": "full_disk", "defer_provisioning": True, "storage": {}}, omarchy_install={"mode": "full_disk", "oem": True, "storage": {}},
user_configuration={"disk_config": {}}, user_configuration={"disk_config": {}},
user_credentials={"users": []}, user_credentials={"users": []},
state_dir=target / "state", state_dir=target / "state",
@@ -173,7 +173,7 @@ def make_ctx(target, **overrides):
return types.SimpleNamespace(**defaults) return types.SimpleNamespace(**defaults)
class StageProvisioningStateTest(unittest.TestCase): class StageOemStateTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.tmp = tempfile.TemporaryDirectory() self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup) self.addCleanup(self.tmp.cleanup)
@@ -192,63 +192,63 @@ class StageProvisioningStateTest(unittest.TestCase):
node_patch.start() node_patch.start()
self.addCleanup(node_patch.stop) self.addCleanup(node_patch.stop)
def install_runtime_provisioning_support(self): def install_runtime_oem_support(self):
service = self.target / "usr/share/omarchy/install/provisioning/omarchy-provision-owner.service" service = self.target / "usr/share/omarchy/install/oem/omarchy-oem-setup.service"
service.parent.mkdir(parents=True, exist_ok=True) service.parent.mkdir(parents=True, exist_ok=True)
service.write_text("[Unit]\n") service.write_text("[Unit]\n")
setup_bin = self.target / "usr/bin/omarchy-provision-owner" setup_bin = self.target / "usr/bin/omarchy-oem-setup"
setup_bin.parent.mkdir(parents=True, exist_ok=True) setup_bin.parent.mkdir(parents=True, exist_ok=True)
setup_bin.write_text("#!/bin/bash\n") setup_bin.write_text("#!/bin/bash\n")
def provisioning_dir(self): def oem_dir(self):
return self.target / "var/lib/omarchy/provisioning" return self.target / "var/lib/omarchy/oem"
def test_normal_install_stages_only_the_node_tarball(self): def test_non_oem_install_stages_only_the_node_tarball(self):
ctx = make_ctx(self.target, defer_provisioning=False) ctx = make_ctx(self.target, oem=False)
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
self.assertTrue((self.provisioning_dir() / "packages/node-v24.0.0-linux-x64.tar.gz").exists()) self.assertTrue((self.oem_dir() / "packages/node-v24.0.0-linux-x64.tar.gz").exists())
self.assertFalse((self.provisioning_dir() / "pending").exists()) self.assertFalse((self.oem_dir() / "pending").exists())
self.assertFalse((self.target / "etc/systemd/system/omarchy-provision-owner.service").exists()) self.assertFalse((self.target / "etc/systemd/system/omarchy-oem-setup.service").exists())
def test_deferred_provisioning_against_runtime_without_support_fails_clearly(self): def test_oem_against_runtime_without_support_fails_clearly(self):
ctx = make_ctx(self.target) ctx = make_ctx(self.target)
with self.assertRaisesRegex(RuntimeError, "does not ship"): with self.assertRaisesRegex(RuntimeError, "does not ship"):
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
def test_deferred_provisioning_without_node_tarball_fails(self): def test_oem_without_node_tarball_fails(self):
for tarball in self.packages.glob("*.tar.gz"): for tarball in self.packages.glob("*.tar.gz"):
tarball.unlink() tarball.unlink()
self.install_runtime_provisioning_support() self.install_runtime_oem_support()
ctx = make_ctx(self.target) ctx = make_ctx(self.target)
with self.assertRaisesRegex(RuntimeError, "Node tarball"): with self.assertRaisesRegex(RuntimeError, "Node tarball"):
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
def test_missing_node_tarball_fails_normal_installs_too(self): def test_missing_node_tarball_fails_normal_installs_too(self):
# The stash is what makes a later factory reset work offline. # The stash is what makes a later factory reset work offline.
for tarball in self.packages.glob("*.tar.gz"): for tarball in self.packages.glob("*.tar.gz"):
tarball.unlink() tarball.unlink()
ctx = make_ctx(self.target, defer_provisioning=False) ctx = make_ctx(self.target, oem=False)
with self.assertRaisesRegex(RuntimeError, "Node tarball"): with self.assertRaisesRegex(RuntimeError, "Node tarball"):
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
def test_deferred_provisioning_arms_first_boot_setup(self): def test_oem_arms_first_boot_setup(self):
self.install_runtime_provisioning_support() self.install_runtime_oem_support()
ctx = make_ctx(self.target) ctx = make_ctx(self.target)
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
self.assertTrue((self.provisioning_dir() / "pending").exists()) self.assertTrue((self.oem_dir() / "pending").exists())
self.assertTrue((self.target / "etc/systemd/system/omarchy-provision-owner.service").exists()) self.assertTrue((self.target / "etc/systemd/system/omarchy-oem-setup.service").exists())
link = self.target / "etc/systemd/system/multi-user.target.wants/omarchy-provision-owner.service" link = self.target / "etc/systemd/system/multi-user.target.wants/omarchy-oem-setup.service"
self.assertTrue(link.is_symlink()) self.assertTrue(link.is_symlink())
self.assertEqual( self.assertEqual(
os.readlink(link), "/etc/systemd/system/omarchy-provision-owner.service" os.readlink(link), "/etc/systemd/system/omarchy-oem-setup.service"
) )
# Unencrypted: no LUKS staging. # Unencrypted: no LUKS staging.
self.assertFalse((self.provisioning_dir() / "luks-key").exists()) self.assertFalse((self.oem_dir() / "luks-key").exists())
def test_deferred_provisioning_encrypted_stages_luks_auto_unlock(self): def test_oem_encrypted_stages_luks_auto_unlock(self):
self.install_runtime_provisioning_support() self.install_runtime_oem_support()
ctx = make_ctx( ctx = make_ctx(
self.target, self.target,
user_configuration={"disk_config": {"disk_encryption": { user_configuration={"disk_config": {"disk_encryption": {
@@ -256,30 +256,30 @@ class StageProvisioningStateTest(unittest.TestCase):
"encryption_password": "throwaway-secret", "encryption_password": "throwaway-secret",
}}}, }}},
) )
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
# Byte-for-byte the slot passphrase — no trailing newline. # Byte-for-byte the slot passphrase — no trailing newline.
self.assertEqual((self.provisioning_dir() / "luks-key").read_text(), "throwaway-secret") self.assertEqual((self.oem_dir() / "luks-key").read_text(), "throwaway-secret")
keyfile = self.target / "etc/omarchy/provisioning.key" keyfile = self.target / "etc/omarchy/oem.key"
self.assertEqual(keyfile.read_text(), "throwaway-secret") self.assertEqual(keyfile.read_text(), "throwaway-secret")
self.assertEqual(keyfile.stat().st_mode & 0o777, 0o600) self.assertEqual(keyfile.stat().st_mode & 0o777, 0o600)
cmdline = (self.target / "etc/limine-entry-tool.d/99-omarchy-provisioning-unlock.conf").read_text() cmdline = (self.target / "etc/limine-entry-tool.d/99-omarchy-oem-unlock.conf").read_text()
self.assertIn("cryptkey=rootfs:/etc/omarchy/provisioning.key", cmdline) self.assertIn("cryptkey=rootfs:/etc/omarchy/oem.key", cmdline)
files = (self.target / "etc/mkinitcpio.conf.d/99-omarchy-provisioning-key.conf").read_text() files = (self.target / "etc/mkinitcpio.conf.d/99-omarchy-oem-key.conf").read_text()
self.assertIn("FILES+=(/etc/omarchy/provisioning.key)", files) self.assertIn("FILES+=(/etc/omarchy/oem.key)", files)
def test_deferred_provisioning_pre_encrypted_without_passphrase_fails(self): def test_oem_pre_encrypted_without_passphrase_fails(self):
self.install_runtime_provisioning_support() self.install_runtime_oem_support()
ctx = make_ctx( ctx = make_ctx(
self.target, self.target,
omarchy_install={"mode": "protected", "defer_provisioning": True, "storage": {"luks_uuid": "abc"}}, omarchy_install={"mode": "protected", "oem": True, "storage": {"luks_uuid": "abc"}},
) )
with self.assertRaisesRegex(RuntimeError, "passphrase"): with self.assertRaisesRegex(RuntimeError, "passphrase"):
phases_impl.stage_provisioning_state(ctx) phases_impl.stage_oem_state(ctx)
class ConfigureLoginDeferProvisioningTest(unittest.TestCase): class ConfigureLoginOemTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.tmp = tempfile.TemporaryDirectory() self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup) self.addCleanup(self.tmp.cleanup)
@@ -293,7 +293,7 @@ class ConfigureLoginDeferProvisioningTest(unittest.TestCase):
run_patch.start() run_patch.start()
self.addCleanup(run_patch.stop) self.addCleanup(run_patch.stop)
def test_deferred_provisioning_login_leaves_user_state_to_first_boot(self): def test_oem_login_leaves_user_state_to_first_boot(self):
ctx = make_ctx(self.target, encrypt=True) ctx = make_ctx(self.target, encrypt=True)
phases_impl.configure_login(ctx) phases_impl.configure_login(ctx)
@@ -303,7 +303,7 @@ class ConfigureLoginDeferProvisioningTest(unittest.TestCase):
self.assertTrue(any("sddm.service" in cmd for cmd in self.calls)) self.assertTrue(any("sddm.service" in cmd for cmd in self.calls))
def test_normal_encrypted_login_still_autologs_in(self): def test_normal_encrypted_login_still_autologs_in(self):
ctx = make_ctx(self.target, defer_provisioning=False, encrypt=True, username="jeff") ctx = make_ctx(self.target, oem=False, encrypt=True, username="jeff")
phases_impl.configure_login(ctx) phases_impl.configure_login(ctx)
autologin = (self.target / "etc/sddm.conf.d/autologin.conf").read_text() autologin = (self.target / "etc/sddm.conf.d/autologin.conf").read_text()
@@ -312,7 +312,7 @@ class ConfigureLoginDeferProvisioningTest(unittest.TestCase):
self.assertIn("User=jeff", state) self.assertIn("User=jeff", state)
class ConfigureSshAccessDeferProvisioningTest(unittest.TestCase): class ConfigureSshAccessOemTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.tmp = tempfile.TemporaryDirectory() self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup) self.addCleanup(self.tmp.cleanup)
@@ -336,14 +336,14 @@ class ConfigureSshAccessDeferProvisioningTest(unittest.TestCase):
run_patch.start() run_patch.start()
self.addCleanup(run_patch.stop) self.addCleanup(run_patch.stop)
def test_deferred_provisioning_stages_keys_for_first_boot(self): def test_oem_stages_keys_for_first_boot(self):
keys = Path(self.tmp.name) / "authorized_keys" keys = Path(self.tmp.name) / "authorized_keys"
keys.write_text("ssh-ed25519 AAAA rig@host\n") keys.write_text("ssh-ed25519 AAAA rig@host\n")
ctx = make_ctx(self.target, authorized_keys_path=keys) ctx = make_ctx(self.target, authorized_keys_path=keys)
phases_impl.configure_ssh_access(ctx) phases_impl.configure_ssh_access(ctx)
staged = self.target / "var/lib/omarchy/provisioning/authorized_keys" staged = self.target / "var/lib/omarchy/oem/authorized_keys"
self.assertEqual(staged.read_text(), "ssh-ed25519 AAAA rig@host\n") self.assertEqual(staged.read_text(), "ssh-ed25519 AAAA rig@host\n")
self.assertEqual(staged.stat().st_mode & 0o777, 0o600) self.assertEqual(staged.stat().st_mode & 0o777, 0o600)
# No user yet — nothing under /home, no chown. # No user yet — nothing under /home, no chown.
@@ -387,7 +387,7 @@ class CreateFactorySnapshotTest(unittest.TestCase):
self.addCleanup(run_patch.stop) self.addCleanup(run_patch.stop)
def ctx(self): def ctx(self):
return make_ctx(self.target, defer_provisioning=False, state_dir=self.state_dir) return make_ctx(self.target, oem=False, state_dir=self.state_dir)
def test_snapshots_root_as_factory(self): def test_snapshots_root_as_factory(self):
phases_impl.create_factory_snapshot(self.ctx()) phases_impl.create_factory_snapshot(self.ctx())
@@ -410,11 +410,11 @@ class CreateFactorySnapshotTest(unittest.TestCase):
top = self.state_dir / "factory-top" top = self.state_dir / "factory-top"
factory = top / "@factory" factory = top / "@factory"
secrets = [ secrets = [
factory / "var/lib/omarchy/provisioning/authorized_keys", factory / "var/lib/omarchy/oem/authorized_keys",
factory / "etc/tailscale/authkey", factory / "etc/tailscale/authkey",
factory / "etc/omarchy/provisioning.key", factory / "etc/omarchy/oem.key",
] ]
keep = factory / "var/lib/omarchy/provisioning/groups" keep = factory / "var/lib/omarchy/oem/groups"
for path in [*secrets, keep]: for path in [*secrets, keep]:
path.parent.mkdir(parents=True, exist_ok=True) path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("secret") path.write_text("secret")