diff --git a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl index 5e5d84e..0108693 100644 --- a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl @@ -160,7 +160,17 @@ if ! is_installed "yay"; then fi {{ else -}} if ! command -v yay &> /dev/null; then - git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -si + if [ "$EUID" -ne 0 ]; then + mkdir -p /tmp/yay-build + useradd -m -G wheel builder && passwd -d builder + chown -R builder:builder /tmp/yay-build + echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + su - builder -c "git clone https://aur.archlinux.org/yay-bin.git /tmp/yay-build/yay" + su - builder -c "cd /tmp/yay-build/yay && makepkg -si --noconfirm" + rm -rf /tmp/yay-build + else + git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -si + fi fi {{ end -}}