refactor-limine

This commit is contained in:
Ryan Hughes
2026-02-17 12:52:50 -05:00
parent 34dbfc0d7c
commit 51c48de1ba
5 changed files with 102 additions and 143 deletions
+10
View File
@@ -168,7 +168,17 @@ def perform_installation(config_file: Path, creds_file: Path | None = None) -> N
snapshot_config = btrfs_options.snapshot_config if btrfs_options else None
snapshot_type = snapshot_config.snapshot_type if snapshot_config else None
if snapshot_type:
# Disable limine-snapper-sync plugin during install (limine not configured yet)
plugin_path = mountpoint / 'usr/lib/snapper/plugins/10-limine-snapper-sync'
plugin_disabled = mountpoint / 'usr/lib/snapper/plugins/10-limine-snapper-sync.disabled'
if plugin_path.exists():
plugin_path.rename(plugin_disabled)
installation.setup_btrfs_snapshot(snapshot_type, config.bootloader)
# Re-enable the plugin after snapper is configured
if plugin_disabled.exists():
plugin_disabled.rename(plugin_path)
info('Mounting offline resources for chroot access...')
from archinstall.lib.general import SysCommand
-1
View File
@@ -1,3 +1,2 @@
run_logged $OMARCHY_INSTALL/login/default-keyring.sh
run_logged $OMARCHY_INSTALL/login/sddm.sh
run_logged $OMARCHY_INSTALL/login/limine-snapper.sh
+91
View File
@@ -0,0 +1,91 @@
#!/bin/bash
# Configure Limine bootloader after archinstall completes
# This runs as part of the login scripts after the system is installed
echo "Configuring Limine bootloader for Omarchy..."
# Detect EFI vs BIOS
if [[ -d /sys/firmware/efi ]]; then
EFI=true
fi
# Create drop-in directory if it doesn't exist
sudo mkdir -p /etc/limine-entry-tool.d
# Only extract cmdline on first install
if [[ ! -f /etc/limine-entry-tool.d/omarchy-cmdline.conf ]]; then
# Extract kernel cmdline from archinstall-created limine config
# Try multiple possible locations (USB, EFI, BIOS)
for config_path in /boot/EFI/BOOT/limine.conf /boot/EFI/limine/limine.conf /boot/limine/limine.conf /boot/limine.conf; do
if [[ -f "$config_path" ]]; then
CMDLINE=$(grep "^[[:space:]]*cmdline:" "$config_path" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//')
OLD_CONFIG="$config_path"
break
fi
done
if [[ -n "$CMDLINE" ]]; then
# Write cmdline to drop-in config file
sudo tee /etc/limine-entry-tool.d/omarchy-cmdline.conf >/dev/null <<EOF
# Omarchy kernel command line parameters
KERNEL_CMDLINE[default]="$CMDLINE"
EOF
# Remove old archinstall-created config
if [[ -n "$OLD_CONFIG" ]]; then
sudo rm "$OLD_CONFIG"
fi
else
echo "ERROR: Could not extract kernel cmdline from limine config" >&2
echo "Please manually create /etc/limine-entry-tool.d/omarchy-cmdline.conf" >&2
exit 1
fi
# Clean up archinstall-created Limine entries
if [[ -n "$EFI" ]] && command -v efibootmgr &>/dev/null; then
while IFS= read -r bootnum; do
sudo efibootmgr -b "$bootnum" -B >/dev/null 2>&1 || true
done < <(efibootmgr 2>/dev/null | grep -E "^Boot[0-9]{4}\*? Arch Linux Limine" | sed 's/^Boot\([0-9]\{4\}\).*/\1/')
fi
fi
# Override UKI settings for BIOS systems
if [[ -z "$EFI" ]]; then
# Disable UKI/fallback for BIOS systems by overriding the shipped config
sudo tee /etc/limine-entry-tool.d/omarchy-uki.conf >/dev/null <<EOF
# BIOS systems don't support UKI or EFI fallback
ENABLE_UKI=no
EOF
fi
# Install themed bootloader config
sudo cp /usr/share/omarchy/limine/limine.conf /boot/limine.conf
# Configure snapper if not already configured
if command -v snapper &>/dev/null; then
# Create configs if they don't exist, using Omarchy template
if ! sudo snapper list-configs 2>/dev/null | grep -q "root"; then
sudo snapper -c root create-config -t omarchy /
fi
if ! sudo snapper list-configs 2>/dev/null | grep -q "home"; then
sudo snapper -c home create-config -t omarchy /home
fi
fi
# Re-enable mkinitcpio hooks if they were disabled during installation
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
# Enable limine-snapper-sync service
chrootable_systemctl_enable limine-snapper-sync.service
# Run limine-update
sudo limine-update 2>/dev/null || true
echo "Limine configuration complete!"
-142
View File
@@ -1,142 +0,0 @@
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
[[ -f /boot/EFI/limine/limine.conf ]] || [[ -f /boot/EFI/BOOT/limine.conf ]] && EFI=true
# Conf location is different between EFI and BIOS
if [[ -n "$EFI" ]]; then
# Check USB location first, then regular EFI location
if [[ -f /boot/EFI/BOOT/limine.conf ]]; then
limine_config="/boot/EFI/BOOT/limine.conf"
else
limine_config="/boot/EFI/limine/limine.conf"
fi
else
limine_config="/boot/limine/limine.conf"
fi
# Double-check and exit if we don't have a config file for some reason
if [[ ! -f $limine_config ]]; then
echo "Error: Limine config not found at $limine_config" >&2
exit 1
fi
CMDLINE=$(grep "^[[:space:]]*cmdline:" "$limine_config" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//')
sudo tee /etc/default/limine <<EOF >/dev/null
TARGET_OS_NAME="Omarchy"
ESP_PATH="/boot"
KERNEL_CMDLINE[default]="$CMDLINE"
KERNEL_CMDLINE[default]+="quiet splash"
ENABLE_UKI=yes
CUSTOM_UKI_NAME="omarchy"
ENABLE_LIMINE_FALLBACK=yes
# Find and add other bootloaders
FIND_BOOTLOADERS=yes
BOOT_ORDER="*, *fallback, Snapshots"
MAX_SNAPSHOT_ENTRIES=5
SNAPSHOT_FORMAT_CHOICE=5
EOF
# 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
# We overwrite the whole thing knowing the limine-update will add the entries for us
sudo tee /boot/limine.conf <<EOF >/dev/null
### Read more at config document: https://github.com/limine-bootloader/limine/blob/trunk/CONFIG.md
#timeout: 3
default_entry: 2
interface_branding: Omarchy Bootloader
interface_branding_color: 2
hash_mismatch_panic: no
term_background: 1a1b26
backdrop: 1a1b26
# Terminal colors (Tokyo Night palette)
term_palette: 15161e;f7768e;9ece6a;e0af68;7aa2f7;bb9af7;7dcfff;a9b1d6
term_palette_bright: 414868;f7768e;9ece6a;e0af68;7aa2f7;bb9af7;7dcfff;c0caf5
# Text colors
term_foreground: c0caf5
term_foreground_bright: c0caf5
term_background_bright: 24283b
EOF
# 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
# 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
# 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}
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
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
# Move this to a utility to allow manual activation
# if [[ -n $EFI ]] && efibootmgr &>/dev/null &&
# ! cat /sys/class/dmi/id/bios_vendor 2>/dev/null | grep -qi "American Megatrends" &&
# ! cat /sys/class/dmi/id/bios_vendor 2>/dev/null | grep -qi "Apple"; then
#
# uki_file=$(find /boot/EFI/Linux/ -name "omarchy*.efi" -printf "%f\n" 2>/dev/null | head -1)
#
# if [[ -n "$uki_file" ]]; then
# sudo efibootmgr --create \
# --disk "$(findmnt -n -o SOURCE /boot | sed 's/p\?[0-9]*$//')" \
# --part "$(findmnt -n -o SOURCE /boot | grep -o 'p\?[0-9]*$' | sed 's/^p//')" \
# --label "Omarchy" \
# --loader "\\EFI\\Linux\\$uki_file"
# fi
# fi
+1
View File
@@ -85,6 +85,7 @@ obs-studio
obsidian
omarchy
omarchy-chromium
omarchy-limine
omarchy-nvim
omarchy-walker
pamixer