104 lines
4.0 KiB
Bash
104 lines
4.0 KiB
Bash
if command -v limine &>/dev/null; then
|
|
sudo pacman -S --noconfirm --needed limine-snapper-sync limine-mkinitcpio-hook
|
|
|
|
sudo tee /etc/mkinitcpio.conf.d/omarchy_hooks.conf <<EOF >/dev/null
|
|
HOOKS=(base udev plymouth keyboard autodetect microcode modconf kms keymap consolefont block encrypt filesystems fsck btrfs-overlayfs)
|
|
EOF
|
|
sudo tee /etc/mkinitcpio.conf.d/thunderbolt_module.conf <<EOF >/dev/null
|
|
MODULES+=(thunderbolt)
|
|
EOF
|
|
|
|
# Detect boot mode
|
|
[[ -d /sys/firmware/efi ]] && EFI=true
|
|
|
|
# Find config location
|
|
if [[ -f /boot/EFI/arch-limine/limine.conf ]]; then
|
|
limine_config="/boot/EFI/arch-limine/limine.conf"
|
|
elif [[ -f /boot/EFI/BOOT/limine.conf ]]; then
|
|
limine_config="/boot/EFI/BOOT/limine.conf"
|
|
elif [[ -f /boot/EFI/limine/limine.conf ]]; then
|
|
limine_config="/boot/EFI/limine/limine.conf"
|
|
elif [[ -f /boot/limine/limine.conf ]]; then
|
|
limine_config="/boot/limine/limine.conf"
|
|
elif [[ -f /boot/limine.conf ]]; then
|
|
limine_config="/boot/limine.conf"
|
|
else
|
|
echo "Error: Limine config not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
CMDLINE=$(grep "^[[:space:]]*cmdline:" "$limine_config" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//')
|
|
|
|
sudo cp $OMARCHY_PATH/default/limine/default.conf /etc/default/limine
|
|
sudo sed -i "s|@@CMDLINE@@|$CMDLINE|g" /etc/default/limine
|
|
|
|
# Append any drop-in kernel cmdline configs (from hardware fix scripts, etc.)
|
|
for dropin in /etc/limine-entry-tool.d/*.conf; do
|
|
[ -f "$dropin" ] && cat "$dropin" | sudo tee -a /etc/default/limine >/dev/null
|
|
done
|
|
|
|
# UKI and EFI fallback are EFI only
|
|
if [[ -z $EFI ]]; then
|
|
sudo sed -i '/^ENABLE_UKI=/d; /^ENABLE_LIMINE_FALLBACK=/d' /etc/default/limine
|
|
fi
|
|
|
|
# Remove the original config file if it's not /boot/limine.conf
|
|
if [[ $limine_config != "/boot/limine.conf" ]] && [[ -f $limine_config ]]; then
|
|
sudo rm "$limine_config"
|
|
fi
|
|
|
|
# We overwrite the whole thing knowing the limine-update will add the entries for us
|
|
sudo cp $OMARCHY_PATH/default/limine/limine.conf /boot/limine.conf
|
|
|
|
# Match Snapper configs if not installing from the ISO
|
|
if [[ -z ${OMARCHY_CHROOT_INSTALL:-} ]]; then
|
|
if ! sudo snapper list-configs 2>/dev/null | grep -q "root"; then
|
|
sudo snapper -c root create-config /
|
|
fi
|
|
|
|
if ! sudo snapper list-configs 2>/dev/null | grep -q "home"; then
|
|
sudo snapper -c home create-config /home
|
|
fi
|
|
fi
|
|
|
|
# Enable quota to allow space-aware algorithms to work
|
|
sudo btrfs quota enable /
|
|
|
|
# Tweak default Snapper configs
|
|
sudo sed -i 's/^TIMELINE_CREATE="yes"/TIMELINE_CREATE="no"/' /etc/snapper/configs/{root,home}
|
|
sudo sed -i 's/^NUMBER_LIMIT="50"/NUMBER_LIMIT="5"/' /etc/snapper/configs/{root,home}
|
|
sudo sed -i 's/^NUMBER_LIMIT_IMPORTANT="10"/NUMBER_LIMIT_IMPORTANT="5"/' /etc/snapper/configs/{root,home}
|
|
sudo sed -i 's/^SPACE_LIMIT="0.5"/SPACE_LIMIT="0.3"/' /etc/snapper/configs/{root,home}
|
|
sudo sed -i 's/^FREE_LIMIT="0.2"/FREE_LIMIT="0.3"/' /etc/snapper/configs/{root,home}
|
|
|
|
chrootable_systemctl_enable limine-snapper-sync.service
|
|
fi
|
|
|
|
echo "Re-enabling mkinitcpio hooks..."
|
|
|
|
# Restore the specific mkinitcpio pacman hooks
|
|
if [[ -f /usr/share/libalpm/hooks/90-mkinitcpio-install.hook.disabled ]]; then
|
|
sudo mv /usr/share/libalpm/hooks/90-mkinitcpio-install.hook.disabled /usr/share/libalpm/hooks/90-mkinitcpio-install.hook
|
|
fi
|
|
|
|
if [[ -f /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook.disabled ]]; then
|
|
sudo mv /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook.disabled /usr/share/libalpm/hooks/60-mkinitcpio-remove.hook
|
|
fi
|
|
|
|
echo "mkinitcpio hooks re-enabled"
|
|
|
|
sudo limine-update
|
|
|
|
# Verify that limine-update actually added boot entries
|
|
if ! grep -q "^/+" /boot/limine.conf; then
|
|
echo "Error: limine-update failed to add boot entries to /boot/limine.conf" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -n $EFI ]] && efibootmgr &>/dev/null; then
|
|
# Remove the archinstall-created Limine entry
|
|
while IFS= read -r bootnum; do
|
|
sudo efibootmgr -b "$bootnum" -B >/dev/null 2>&1
|
|
done < <(efibootmgr | grep -E "^Boot[0-9]{4}\*? Arch Linux Limine" | sed 's/^Boot\([0-9]\{4\}\).*/\1/')
|
|
fi
|