Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bin/omarchy-agent-account-exec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ fi
# avoid recursion, but the agent's subprocesses need them for other providers.
if ! agent_binary=$(type -P "$provider"); then
# A mise dispatcher can exist before its CLI or first-run installer does.
export MISE_MINIMUM_RELEASE_AGE=0
mise use -g --quiet "$provider"
agent_binary=$(mise which "$provider")
fi
Expand Down
7 changes: 2 additions & 5 deletions bin/omarchy-mise-install
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ case "$bin" in
*) bin_arg="\"$bin\"" ;;
esac

# These tools install and upgrade on first run, so mise's release cooldown would
# hold a new version back for days after it ships. Exported rather than set on
# the install line alone, so resolving the version to execute agrees with the
# one just installed.
# Let mise apply its configured release-age policy on first use as well as
# updates. Explicit environment overrides remain the user's choice.
rm -f "$HOME/.local/bin/$command"
cat >"$HOME/.local/bin/$command" <<EOF
#!/bin/bash
export MISE_MINIMUM_RELEASE_AGE=0
mise use -g --quiet $package_arg || exit 1
exec mise x $package_arg -- $bin_arg "\$@"
EOF
Expand Down
46 changes: 37 additions & 9 deletions bin/omarchy-pkg-aur-install
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
#!/bin/bash
#!/bin/bash -p

# omarchy:summary=Show a fuzzy-finder TUI for picking new AUR packages to install.
# omarchy:requires-sudo=true

# PKGBUILDs are third-party code. Protect the cold credential boundary before
# shell startup files or exported functions can run, just as omarchy update does.
if [[ $- != *p* ]]; then
echo "Refusing an unsafe Bash startup." >&2
exit 126
fi

security_entrypoint=$(/usr/bin/readlink -e -- "${BASH_SOURCE[0]}") || exit 126
source "${security_entrypoint%/*}/omarchy-security-functions" || exit 126
omarchy_security_require_privileged_bash_startup || exit 126
set -e
omarchy_security_sanitize_bash_environment "$0" "$@"
omarchy_security_require_source_root "$0"
omarchy_security_install_sudo_cleanup_traps
omarchy_security_revoke_sudo_timestamp || exit 1
omarchy_security_enable_no_update_sudo
unset OMARCHY_UPDATE_SUDO_SESSION

fzf_args=(
--multi
--preview 'yay -Siia {1}'
Expand All @@ -17,14 +35,24 @@ fzf_args=(
--color 'pointer:green,marker:green'
)

pkg_names=$(yay -Slqa | fzf "${fzf_args[@]}")
selection_status=0
pkg_names=$(yay -Slqa | fzf "${fzf_args[@]}") || selection_status=$?
case $selection_status in
0) ;;
1 | 130) exit 0 ;; # No match or the user cancelled.
*) exit "$selection_status" ;;
esac

if [[ -n $pkg_names ]]; then
# Add aur/ prefix to each package name and convert to space-separated for yay
source omarchy-sudo-keepalive

echo "$pkg_names" | sed 's/^/aur\//' | tr '\n' ' ' | xargs yay -S --noconfirm
code=$?
sudo updatedb --prune-bind-mounts=no --add-prunepaths=/.snapshots
omarchy-show-done $code
# Keep each selected package one operand; yay and any bare sudo in a build
# authenticate without publishing a reusable timestamp.
mapfile -t packages <<<"$pkg_names"
packages=("${packages[@]/#/aur/}")
code=0
yay --sudo "$OMARCHY_PATH/default/omarchy/sudo-no-update/sudo" --sudoloop=false -S --noconfirm -- "${packages[@]}" || code=$?
omarchy_security_revoke_sudo_timestamp
# File indexing belongs to the scheduled plocate service, not an interactive
# install: a full filesystem scan can otherwise outlast the installation.
omarchy-show-done "$code"
exit "$code"
fi
35 changes: 24 additions & 11 deletions bin/omarchy-update
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ unset OMARCHY_UPDATE_USER_PATH
# prompt below always belongs to this update, never to an earlier session.
omarchy_security_install_sudo_cleanup_traps
omarchy_security_revoke_sudo_timestamp || exit 1
# Validate the no-update wrapper up front: the AUR phase depends on it. Every
# other phase shares the one authorization, so it stays off PATH until then.
# Validate the no-update wrapper before authorizing the trusted system phases.
# Hooks and third-party installers use it after that authorization is revoked.
omarchy_security_enable_no_update_sudo
PATH="$OMARCHY_PATH/bin:/usr/bin:/usr/sbin:/bin:/sbin"
unset OMARCHY_SUDO_NO_UPDATE
Expand All @@ -37,8 +37,8 @@ export PATH OMARCHY_UPDATE_SUDO_SESSION=1
update_stay_awake_stopped=0
sudo_keepalive_pid=""

# Ask for the password once, then keep sudo's timestamp fresh so long package
# downloads, migrations, hooks, and mise never outlast it and prompt again.
# Ask for the password once, then keep sudo's timestamp fresh so system-package
# downloads and migrations never outlast it and prompt again.
# Authorize by running a command rather than sudo -v: under the default
# verifypw=all, -v prompts even when passwordless sudo is enabled.
authorize_update() {
Expand Down Expand Up @@ -96,8 +96,6 @@ trap 'echo ""; echo -e "\033[0;31mSomething went wrong during the update!\n\nPle
trap cleanup_update EXIT
omarchy_security_install_signal_exit_traps

omarchy-update-requires-free-space

# -y suppresses Omarchy confirmation prompts; sudo authorization is still
# required. Interactive review steps report and move on instead of waiting.
[[ ${1:-} != "-y" ]] || export OMARCHY_UPDATE_UNATTENDED=1
Expand All @@ -108,6 +106,9 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then
# Before the snapshot: the cache is on the snapshotted subvolume, so pruning
# after it frees nothing until that snapshot ages out.
omarchy-update-pkg-prune
# Give bounded cache cleanup a chance to recover a low-space system, but
# never snapshot or change packages unless the original space guard passes.
omarchy-update-requires-free-space

# 127 means Snapper is deliberately absent. Any other failure already said
# what went wrong, and a missing snapshot is not worth blocking an update
Expand Down Expand Up @@ -136,15 +137,27 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then
# performs no privileged work.
omarchy-update-restart --services-only

# Hooks and mise run with the caller's PATH so user-installed tools resolve.
PATH="$user_path" "$OMARCHY_PATH/bin/omarchy-hook" post-update
PATH="$user_path" "$OMARCHY_PATH/bin/omarchy-update-mise"
# Downloaded mise installers must not inherit system-update authorization.
# Hooks may invoke them too, so end the trusted phase before either runs.
end_update_authorization
unset OMARCHY_UPDATE_SUDO_SESSION
# A package transaction may replace the running checkout with an older
# release. Do not let a missing wrapper silently fall through to plain sudo.
if [[ ! -x $OMARCHY_PATH/default/omarchy/sudo-no-update/sudo ]]; then
echo "The sudo boundary changed during the update. Start the installed release's update from a fresh terminal." >&2
exit 1
fi
# Keep user tools reachable, with command-scoped sudo first. Revoke between
# phases too: a hook may deliberately invoke /usr/bin/sudo directly.
PATH="$OMARCHY_PATH/default/omarchy/sudo-no-update:$user_path" OMARCHY_SUDO_NO_UPDATE=1 "$OMARCHY_PATH/bin/omarchy-hook" post-update
omarchy_security_revoke_sudo_timestamp
PATH="$OMARCHY_PATH/default/omarchy/sudo-no-update:$user_path" OMARCHY_SUDO_NO_UPDATE=1 "$OMARCHY_PATH/bin/omarchy-update-mise"
omarchy_security_revoke_sudo_timestamp

# AUR builds run third-party PKGBUILD code, so they go last and never see the
# update's authorization: revoke it, then authenticate each sudo call with
# update's authorization: authenticate each sudo call with
# the no-update wrapper, for yay and any bare sudo a PKGBUILD runs, so an AUR
# install prompts without caching anything.
end_update_authorization
PATH="$OMARCHY_PATH/default/omarchy/sudo-no-update:$PATH" OMARCHY_SUDO_NO_UPDATE=1 omarchy-update-aur-pkgs
omarchy_security_revoke_sudo_timestamp

Expand Down
28 changes: 21 additions & 7 deletions bin/omarchy-update-aur-pkgs
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
#!/bin/bash
#!/bin/bash -p

# omarchy:summary=Update AUR packages if any are installed
# omarchy:requires-sudo=true

sudo_options=()
if [[ ${OMARCHY_SUDO_NO_UPDATE:-0} == "1" ]]; then
sudo_wrapper="$OMARCHY_PATH/default/omarchy/sudo-no-update/sudo"
[[ -x $sudo_wrapper ]] || exit 1
sudo_options=(--sudo "$sudo_wrapper" --sudoloop=false)
# This helper is also a direct CLI entrypoint. Establish the same cold boundary
# whether the full updater called it or the user requested only AUR updates.
# Privileged Bash suppresses startup injection before credentials are revoked.
if [[ $- != *p* ]]; then
echo "Refusing an unsafe Bash startup." >&2
exit 126
fi

security_entrypoint=$(/usr/bin/readlink -e -- "${BASH_SOURCE[0]}") || exit 126
source "${security_entrypoint%/*}/omarchy-security-functions" || exit 126
omarchy_security_require_privileged_bash_startup || exit 126
set -e
omarchy_security_sanitize_bash_environment "$0" "$@"
omarchy_security_require_source_root "$0"
omarchy_security_install_sudo_cleanup_traps
omarchy_security_revoke_sudo_timestamp || exit 1
omarchy_security_enable_no_update_sudo
unset OMARCHY_UPDATE_SUDO_SESSION
sudo_wrapper="$OMARCHY_PATH/default/omarchy/sudo-no-update/sudo"

if pacman -Qem >/dev/null; then
if omarchy-pkg-aur-accessible; then
echo -e "\e[32m\nUpdate AUR packages\e[0m"
yay "${sudo_options[@]}" -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs || exit 1
yay --sudo "$sudo_wrapper" --sudoloop=false -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs || exit 1
echo
else
echo -e "\e[31m\nAUR is unavailable (so skipping updates)\e[0m"
Expand Down
7 changes: 3 additions & 4 deletions bin/omarchy-update-mise
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
if omarchy-cmd-present mise; then
echo -e "\e[32m\nUpdate mise tools\e[0m"

# mise withholds releases younger than its cooldown, so tools stay behind for
# days after they ship. Running omarchy update is the user asking for current
# versions now, which is the same call the mup alias makes by hand.
MISE_MINIMUM_RELEASE_AGE=0 mise up
# Respect mise's configured release-age policy, including an explicit
# override supplied by the user for an urgent update.
mise up
fi
2 changes: 1 addition & 1 deletion default/bash/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ alias h='herdr'
alias ic='tdl c'
alias ix='tdl cx'
alias icx='tdl c cx'
alias mup='MISE_MINIMUM_RELEASE_AGE=0 mise up'
alias mup='mise up'
n() { if [ "$#" -eq 0 ]; then command nvim . ; else command nvim "$@"; fi; }

# Git
Expand Down
Loading