Drop the kms hook when the proprietary NVIDIA driver handles early KMS (#6791)
* Drop the kms hook when the proprietary NVIDIA driver handles early KMS install/hardware/nvidia.sh early-loads nvidia_drm (modeset=1) for early KMS, but HOOKS still carried the kms hook, so autodetect pulled nouveau and ~100 MB of its GSP firmware into every initramfs for a driver that never runs. On a Limine UKI setup that meant a 256 MB image where ~144 MB is normal, doubled again by the fallback history on /boot. Filter kms out of HOOKS when nvidia_drm is in MODULES (nvidia.conf sorts before this drop-in) and every PCI display controller is NVIDIA. Hybrid systems keep kms so the iGPU retains early KMS at the LUKS prompt. Verified on an RTX 4090 (nvidia-open-dkms 610.57.04): UKI shrinks 256,183,296 -> 144,066,048 bytes, nouveau and its firmware gone, the nvidia-utils GSP blobs and all four nvidia modules retained, Plymouth still owns the LUKS prompt via nvidia_drm. Fixes #6790 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Address review: quote literals, harden PCI detection, add shell tests Quote fixed string literals in the [[ ]] comparisons per AGENTS.md, and read the PCI tree through OMARCHY_PCI_DEVICES_PATH, the same seam bin/omarchy-hw-nvidia already uses. Require a positively identified NVIDIA display controller before dropping kms: an empty or unreadable PCI tree previously counted as "no non-NVIDIA GPU" and would have dropped the hook. Unexpected trees now keep kms. Cover the conditional in test/shell.d/nvidia-kms-hook-test.sh: nvidia-only, hybrid, no nvidia_drm, MODULES unset under set -u, audio-function-only, empty tree, and a device directory missing its sysfs attributes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Treat unreadable PCI devices as inconclusive and make the test hermetic A device whose class/vendor attributes cannot be read could be another GPU, so skipping it let a readable NVIDIA GPU beside it drop kms without having verified the whole tree. Count it as a non-NVIDIA sighting so kms stays, and cover the mixed case in the test. The test also sourced the host's /etc/vconsole.conf under set -u, where a valid KEYMAP-only file makes the XKBLAYOUT expansion fail in the subshell and ties the result to the machine running it. Predefine XKBLAYOUT and FILES before sourcing the config. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Rebuild existing initramfses once the kms hook no longer applies The settings package deploys the new omarchy_hooks.conf conditional, but nothing rebuilds the initramfs when only a mkinitcpio drop-in changes, so existing NVIDIA-only installs would carry nouveau's ~100 MB of GSP firmware until their next kernel update. Following the precedent of 1784476564, add a migration that rebuilds via limine-mkinitcpio — once per machine, and only where evaluating the installed drop-ins shows the conditional actually dropped kms, so hybrid machines, non-NVIDIA machines, and user-edited configs are left alone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Document the mid-sourcing MODULES caveat in the kms conditional A later-sorting drop-in that resets MODULES outright (as surface_device_modules.conf does) would strip nvidia_drm after kms was already dropped. Every machine Omarchy writes such a file for is hybrid Intel and keeps kms through the PCI scan, but that is worth stating so the invariant is not broken by accident. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
co-authored by
Claude Fable 5
David Heinemeier Hansson
parent
6fad76184f
commit
ecd57bceee
@@ -0,0 +1,33 @@
|
||||
echo "Rebuild the initramfs so NVIDIA-only systems shed nouveau's unused GSP firmware"
|
||||
|
||||
# omarchy_hooks.conf now filters the kms hook out of HOOKS when the proprietary
|
||||
# NVIDIA driver handles early KMS and NVIDIA owns every display controller
|
||||
# (#6790). The settings package deploys that conditional, but nothing rebuilds
|
||||
# the initramfs for a mkinitcpio drop-in change, so affected machines would
|
||||
# carry ~100 MB of dead nouveau firmware until their next kernel update.
|
||||
# Rebuild once, and only where the conditional actually changes the outcome:
|
||||
# evaluate the installed drop-ins the way mkinitcpio does and check that kms
|
||||
# dropped out. A user-edited omarchy_hooks.conf (pacman leaves the packaged
|
||||
# update as a .pacnew) keeps kms and correctly skips the rebuild.
|
||||
|
||||
hooks_conf="${OMARCHY_MKINITCPIO_HOOKS_CONF:-/etc/mkinitcpio.conf.d/omarchy_hooks.conf}"
|
||||
nvidia_conf="${OMARCHY_MKINITCPIO_NVIDIA_CONF:-/etc/mkinitcpio.conf.d/nvidia.conf}"
|
||||
rebuild_marker="${OMARCHY_KMS_REBUILD_MARKER:-/var/lib/omarchy/migrations/1786605598}"
|
||||
|
||||
omarchy-cmd-present limine-mkinitcpio || exit 0
|
||||
[[ -f $hooks_conf && -f $nvidia_conf ]] || exit 0
|
||||
|
||||
# The rebuild is machine-wide, but migrations run once per user: a marker
|
||||
# records completion so another user's run does not repeat it, while a missing
|
||||
# marker still retries an interrupted rebuild.
|
||||
[[ ! -e $rebuild_marker ]] || exit 0
|
||||
|
||||
# Source the drop-ins in mkinitcpio's order (nvidia.conf sorts first) and read
|
||||
# the HOOKS they produce. Skip conservatively if evaluation fails.
|
||||
hooks=$(bash -c 'source "$1" && source "$2" && echo " ${HOOKS[*]} "' -- "$nvidia_conf" "$hooks_conf") || exit 0
|
||||
|
||||
[[ $hooks != *" kms "* ]] || exit 0
|
||||
|
||||
echo "This machine no longer uses the kms hook; rebuilding the initramfs without nouveau"
|
||||
sudo limine-mkinitcpio
|
||||
sudo install -Dm644 /dev/null "$rebuild_marker"
|
||||
Reference in New Issue
Block a user