Files
omarchycn/bin/omarchy-apply-system
T
David Heinemeier HanssonandClaude Opus 5 536fcd5c6c Move install-time plumbing out of the setup namespace
setup is where a user goes to configure something: direct boot, security
keys, hibernation. These three are not that. omarchy-apply-system is the
ISO's entry point in the target chroot, omarchy-apply-hardware is what it
calls for device quirks, and omarchy-apply-lock is called by
install/config/lockscreen-pam.sh.

apply is the verb they already used to describe themselves, and it carries
the contract: declared state under install/ converged onto the machine,
idempotent, safe to repeat.

The group gets no GROUP_DESCRIPTIONS entry on purpose. That table drives the
top-level group list on its own, so an entry would put apply back in front of
users even with every command in it hidden, the way provision already stays
out. A test covers it.

The ISO installs the runtime from the mirror it ships with, so it moves to
the new names in lockstep and no compatibility route is needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-10 14:14:57 -07:00

103 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# omarchy:summary=Apply Omarchy system setup in the installed target
# omarchy:group=apply
# omarchy:requires-sudo=true
# omarchy:examples=omarchy apply system --install-user dhh --first-install
# omarchy:hidden=true
set -euo pipefail
usage() {
cat <<USAGE
Usage: omarchy apply system --install-user USER [--first-install|--upgrade]
omarchy apply system --defer-provisioning --first-install
Runs root-owned Omarchy system setup. The ISO calls this in the target chroot
after packages are installed and the target user exists. It also calls
omarchy-apply-hardware, so hardware setup cannot be accidentally skipped.
--defer-provisioning runs without an install user: deferred-provisioning installs create the user at
first boot, so scripts that grant group memberships record them in
/var/lib/omarchy/provisioning/groups instead of calling usermod.
USAGE
}
install_user="${OMARCHY_INSTALL_USER:-}"
first_install=0
upgrade=0
defer_provisioning=0
while (($#)); do
case "$1" in
--install-user)
install_user="${2:-}"
shift 2
;;
--defer-provisioning)
defer_provisioning=1
shift
;;
--first-install)
first_install=1
shift
;;
--upgrade)
upgrade=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
done
if (( EUID != 0 )); then
echo "Error: omarchy-apply-system must run as root" >&2
exit 1
fi
if (( defer_provisioning )); then
install_user=""
else
if [[ -z $install_user || $install_user == "root" ]]; then
echo "Error: --install-user must name the target non-root user" >&2
exit 1
fi
if ! getent passwd "$install_user" >/dev/null; then
echo "Error: user '$install_user' does not exist" >&2
exit 1
fi
fi
export OMARCHY_INSTALL_USER="$install_user"
export OMARCHY_FIRST_INSTALL="$first_install"
export OMARCHY_UPGRADE="$upgrade"
export OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
export OMARCHY_INSTALL="${OMARCHY_INSTALL:-$OMARCHY_PATH/install}"
export OMARCHY_INSTALL_LOG_FILE="${OMARCHY_INSTALL_LOG_FILE:-/var/log/omarchy-install.log}"
export PATH="$OMARCHY_PATH/bin:$PATH"
source "$OMARCHY_INSTALL/helpers/logging.sh"
start_install_log
source "$OMARCHY_INSTALL/config/all.sh"
if (( defer_provisioning )); then
omarchy-apply-hardware --defer-provisioning
else
omarchy-apply-hardware --install-user "$install_user"
fi
source "$OMARCHY_INSTALL/login/all.sh"
source "$OMARCHY_INSTALL/post-install/all.sh"
stop_install_log