* 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>
104 lines
3.3 KiB
Bash
Executable File
104 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
|
|
|
tmp_dir=$(mktemp -d)
|
|
trap 'rm -rf "$tmp_dir"' EXIT
|
|
|
|
hooks_conf="$ROOT/etc/mkinitcpio.conf.d/omarchy_hooks.conf"
|
|
|
|
# Each argument is a PCI device as "vendor:class", in sysfs's own format.
|
|
write_pci_devices() {
|
|
rm -rf "$tmp_dir/devices"
|
|
mkdir -p "$tmp_dir/devices"
|
|
|
|
local index=0
|
|
local spec
|
|
for spec in "$@"; do
|
|
local slot
|
|
slot=$(printf '0000:%02x:00.0' "$index")
|
|
mkdir -p "$tmp_dir/devices/$slot"
|
|
printf '%s\n' "${spec%%:*}" >"$tmp_dir/devices/$slot/vendor"
|
|
printf '%s\n' "${spec##*:}" >"$tmp_dir/devices/$slot/class"
|
|
index=$((index + 1))
|
|
done
|
|
}
|
|
|
|
# Sources the hook config the way mkinitcpio does — with earlier drop-ins
|
|
# already applied — and prints the resulting HOOKS. mkinitcpio does not run
|
|
# under set -u, but the config must survive it, so source under it anyway.
|
|
# "unset" leaves MODULES undeclared entirely.
|
|
resolved_hooks() {
|
|
local modules_decl=""
|
|
[[ $1 == "unset" ]] || modules_decl="MODULES=($1)"
|
|
|
|
# The vconsole block sources the host's /etc/vconsole.conf, which may set
|
|
# only KEYMAP; predefine XKBLAYOUT so its expansion survives set -u and the
|
|
# test stays independent of the machine it runs on.
|
|
OMARCHY_PCI_DEVICES_PATH="$tmp_dir/devices" bash -uc "
|
|
FILES=()
|
|
XKBLAYOUT=us
|
|
$modules_decl
|
|
source '$hooks_conf'
|
|
echo \"\${HOOKS[*]}\"
|
|
"
|
|
}
|
|
|
|
nvidia_modules="nvidia nvidia_modeset nvidia_uvm nvidia_drm"
|
|
|
|
write_pci_devices
|
|
with_kms=$(resolved_hooks "")
|
|
without_kms=${with_kms/ kms / }
|
|
|
|
[[ $with_kms == *" kms "* ]] ||
|
|
fail "baseline HOOKS contains the kms hook" "actual: $with_kms"
|
|
pass "baseline HOOKS contains the kms hook"
|
|
|
|
assert_hooks() {
|
|
local description="$1" modules="$2" expected="$3"
|
|
local actual
|
|
actual=$(resolved_hooks "$modules")
|
|
|
|
[[ $actual == "$expected" ]] ||
|
|
fail "$description" "expected: $expected"$'\n'"actual: $actual"
|
|
pass "$description"
|
|
}
|
|
|
|
# NVIDIA RTX class display controller.
|
|
write_pci_devices 0x10de:0x030000
|
|
assert_hooks "nvidia-only system with early nvidia_drm drops only kms" \
|
|
"$nvidia_modules" "$without_kms"
|
|
assert_hooks "nvidia-only system without early nvidia_drm keeps kms" \
|
|
"" "$with_kms"
|
|
assert_hooks "unset MODULES under set -u keeps kms without erroring" \
|
|
"unset" "$with_kms"
|
|
|
|
# AMD integrated graphics next to an NVIDIA 3D controller.
|
|
write_pci_devices 0x1002:0x030000 0x10de:0x030200
|
|
assert_hooks "hybrid system keeps kms for the iGPU" \
|
|
"$nvidia_modules" "$with_kms"
|
|
|
|
# NVIDIA audio function only: no display controller found.
|
|
write_pci_devices 0x10de:0x040300
|
|
assert_hooks "no display controller found keeps kms" \
|
|
"$nvidia_modules" "$with_kms"
|
|
|
|
write_pci_devices
|
|
assert_hooks "empty PCI tree keeps kms" \
|
|
"$nvidia_modules" "$with_kms"
|
|
|
|
# A device directory missing its class/vendor attributes must not error, and
|
|
# counts as inconclusive: it could be another GPU, so kms stays.
|
|
write_pci_devices
|
|
mkdir -p "$tmp_dir/devices/0000:00:00.0"
|
|
assert_hooks "unreadable PCI device keeps kms" \
|
|
"$nvidia_modules" "$with_kms"
|
|
|
|
# Even next to a readable NVIDIA GPU — the unreadable device may be the iGPU.
|
|
write_pci_devices 0x10de:0x030000
|
|
mkdir -p "$tmp_dir/devices/0000:01:00.0"
|
|
assert_hooks "unreadable device beside an NVIDIA GPU keeps kms" \
|
|
"$nvidia_modules" "$with_kms"
|