diff --git a/bin/omarchy-channel-set b/bin/omarchy-channel-set index 3ee406a4..7e112388 100755 --- a/bin/omarchy-channel-set +++ b/bin/omarchy-channel-set @@ -12,15 +12,12 @@ fail() { echo "Error: $*" >&2; exit 1; } confirm_dev() { cat <<'WARNING' -Dev links Omarchy directly to a mutable source checkout. - -This disables package-based protections for the Omarchy code path, including -normal package updates and package-backed snapshot restores. You'll be -responsible for pulling, fixing, and restoring that checkout yourself. +The dev channel links Omarchy directly to a checkout of the source in ~/omarchy. +It's exclusively intended for developers working on Omarchy itself. WARNING - gum confirm --default=false "Enable Dev anyway?" + gum confirm --default=false "Switch to dev channel?" } validate_dev_checkout() { @@ -39,7 +36,7 @@ link_dev_checkout() { local checkout="$1" [[ -d $checkout/.git ]] || git clone https://github.com/basecamp/omarchy.git "$checkout" - omarchy-dev-link "$checkout" + omarchy-dev-link "$checkout" --no-reboot } (( $# > 0 )) || { usage; exit 1; } @@ -79,6 +76,13 @@ if [[ -z $dev_checkout && $OMARCHY_PATH != "/usr/share/omarchy" ]]; then leaving_dev=1 fi +if [[ -n $dev_checkout ]]; then + link_dev_checkout "$dev_checkout" + export OMARCHY_PATH="$dev_checkout" + export PATH="$OMARCHY_PATH/bin:$PATH" + omarchy-state set reboot-required +fi + omarchy-refresh-pacman "$pacman_channel" # --ask 4 accepts omarchy <-> omarchy-dev replacement prompts without file overwrites. sudo env OMARCHY_UPDATE_PACMAN=1 pacman -S --needed --noconfirm --ask 4 "${packages[@]}" @@ -93,7 +97,3 @@ if [[ -z $dev_checkout ]]; then fi omarchy-update -y - -if [[ -n $dev_checkout ]]; then - link_dev_checkout "$dev_checkout" -fi diff --git a/bin/omarchy-dev-link b/bin/omarchy-dev-link index d7fd6e52..00fba9d8 100755 --- a/bin/omarchy-dev-link +++ b/bin/omarchy-dev-link @@ -2,7 +2,7 @@ # omarchy:summary=Point Omarchy at a local checkout after reboot # omarchy:group=dev -# omarchy:args= +# omarchy:args= [--no-reboot] # omarchy:examples=omarchy dev link ~/omarchy set -euo pipefail @@ -12,9 +12,11 @@ if (( EUID == 0 )); then exit 1 fi -if (( $# != 1 )) || [[ $1 == "-h" || $1 == "--help" ]]; then +prompt_reboot=1 + +if (( $# < 1 || $# > 2 )) || [[ $1 == "-h" || $1 == "--help" ]]; then cat < +Usage: omarchy dev link [--no-reboot] Writes /etc/omarchy.conf so OMARCHY_PATH resolves to after reboot. This intentionally does not rewrite the running Hyprland, @@ -25,10 +27,21 @@ themes/, applications/, config/. Files installed at fixed system paths (/etc/, /usr/lib/systemd/, udev rule bodies, /etc/skel after user creation, /usr/share/plymouth) are NOT covered — for those, use omarchy-dev-pkg-test to build and install the package from the checkout. + +Use --no-reboot when another command will handle the reboot prompt. USAGE exit 0 fi +if (( $# == 2 )); then + if [[ $2 == "--no-reboot" ]]; then + prompt_reboot=0 + else + echo "Usage: omarchy dev link [--no-reboot]" >&2 + exit 1 + fi +fi + omarchy_conf_quote() { local value="$1" value=${value//\\/\\\\} @@ -58,6 +71,6 @@ done echo "Pointed Omarchy at $target" echo -if gum confirm "Reboot now to activate?"; then +if (( prompt_reboot )) && gum confirm "Reboot now to activate?"; then omarchy-system-reboot fi diff --git a/test/shell.d/channel-test.sh b/test/shell.d/channel-test.sh index 1c0d2faf..664e17c5 100644 --- a/test/shell.d/channel-test.sh +++ b/test/shell.d/channel-test.sh @@ -46,6 +46,7 @@ printf "\n" >>"$OMARCHY_CHANNEL_TEST_LOG" write_stub omarchy-update '#!/bin/bash printf "update" >>"$OMARCHY_CHANNEL_TEST_LOG" for arg in "$@"; do printf "\t%s" "$arg" >>"$OMARCHY_CHANNEL_TEST_LOG"; done +printf "\tOMARCHY_PATH=%s" "$OMARCHY_PATH" >>"$OMARCHY_CHANNEL_TEST_LOG" printf "\n" >>"$OMARCHY_CHANNEL_TEST_LOG" ' @@ -107,7 +108,7 @@ run_channel stable assert_log_line $'refresh\tstable' "stable refreshes the stable pacman channel" assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy\tomarchy-settings' "stable installs stable Omarchy packages" assert_log_line $'unlink\t--no-reboot' "stable restores the package-backed Omarchy path without an early reboot prompt" -assert_log_line $'update\t-y' "stable runs the normal update pipeline" +assert_log_line $'update\t-y\tOMARCHY_PATH=/usr/share/omarchy' "stable runs the normal update pipeline from the package-backed path" if grep -q $'^state\tset\treboot-required$' "$log_file"; then fail "stable does not require reboot when already package-backed" "$(cat "$log_file")" fi @@ -117,15 +118,15 @@ run_channel rc assert_log_line $'refresh\trc' "rc refreshes the rc pacman channel" assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy\tomarchy-settings' "rc installs rc Omarchy packages" assert_log_line $'unlink\t--no-reboot' "rc restores the package-backed Omarchy path without an early reboot prompt" -assert_log_line $'update\t-y' "rc runs the normal update pipeline" +assert_log_line $'update\t-y\tOMARCHY_PATH=/usr/share/omarchy' "rc runs the normal update pipeline from the package-backed path" OMARCHY_TEST_PATH="$ROOT" run_channel edge assert_log_line $'refresh\tedge' "edge refreshes the edge pacman channel" assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "edge installs development Omarchy packages" assert_log_line $'unlink\t--no-reboot' "edge unlinks dev without an early reboot prompt" assert_log_line $'state\tset\treboot-required' "edge marks reboot required when leaving dev" -assert_log_line $'update\t-y' "edge runs the normal update pipeline" -[[ $(grep -E '^(unlink|state|update)' "$log_file") == $'unlink\t--no-reboot\nstate\tset\treboot-required\nupdate\t-y' ]] || +assert_log_line $'update\t-y\tOMARCHY_PATH=/usr/share/omarchy' "edge runs the normal update pipeline from the package-backed path" +[[ $(grep -E '^(unlink|state|update)' "$log_file") == $'unlink\t--no-reboot\nstate\tset\treboot-required\nupdate\t-y\tOMARCHY_PATH=/usr/share/omarchy' ]] || fail "edge defers the reboot prompt until the update restart stage" "$(cat "$log_file")" pass "edge defers the reboot prompt until the update restart stage" @@ -143,11 +144,16 @@ pass "dev refuses occupied non-checkout paths before package changes" rmdir "$checkout" run_channel dev -assert_log_line $'gum\tconfirm\t--default=false\tEnable Dev anyway?' "dev asks for confirmation" +assert_log_line $'gum\tconfirm\t--default=false\tSwitch to dev channel?' "dev asks for confirmation" assert_log_line $'refresh\tedge' "dev refreshes the edge pacman channel" assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "dev installs development Omarchy packages" assert_log_line $'git\tclone\thttps://github.com/basecamp/omarchy.git\t'"$checkout" "dev clones the source checkout to ~/omarchy" -assert_log_line $'link\t'"$checkout" "dev links ~/omarchy" +assert_log_line $'link\t'"$checkout"$'\t--no-reboot' "dev links ~/omarchy without an early reboot prompt" +assert_log_line $'state\tset\treboot-required' "dev defers the reboot prompt to the update pipeline" +assert_log_line $'update\t-y\tOMARCHY_PATH='"$checkout" "dev runs the normal update pipeline from the source checkout" +[[ $(grep -E '^(git|link|state|refresh|sudo|update)' "$log_file") == $'git\tclone\thttps://github.com/basecamp/omarchy.git\t'"$checkout"$'\nlink\t'"$checkout"$'\t--no-reboot\nstate\tset\treboot-required\nrefresh\tedge\nsudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev\nupdate\t-y\tOMARCHY_PATH='"$checkout" ]] || + fail "dev activates the checkout before changing or updating packages" "$(cat "$log_file")" +pass "dev activates the checkout before changing or updating packages" OMARCHY_TEST_PATH="$checkout" run_channel stable assert_log_line $'unlink\t--no-reboot' "switching from dev to stable unlinks without an early reboot prompt" @@ -157,7 +163,7 @@ run_channel dev if grep -q $'^git\tclone\t' "$log_file"; then fail "dev reuses an existing checkout" "$(cat "$log_file")" fi -assert_log_line $'link\t'"$checkout" "switching back to dev links ~/omarchy" +assert_log_line $'link\t'"$checkout"$'\t--no-reboot' "switching back to dev links ~/omarchy" pass "switching back to dev reuses the existing ~/omarchy checkout" current_channel() {