Skip to content

Append the Surface keyboard modules instead of resetting MODULES - #14541

Open
omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-7111
Open

omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-7111

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

install/hardware/fix-surface-keyboard.sh wrote surface_device_modules.conf as MODULES=(...). mkinitcpio concatenates its drop-ins in sorted order after /etc/mkinitcpio.conf, and that file sorts after nvidia.conf, so on a Surface with an NVIDIA GPU the reset removed nvidia nvidia_modeset nvidia_uvm nvidia_drm from MODULES, along with anything the main config or an earlier drop-in listed. The installer now appends, as nvidia.conf, apple-t2.conf and thunderbolt_module.conf already do.

Existing installs keep the file they were given, so a migration repairs it and rebuilds the initramfs once per machine. It matches only the file the installer wrote, whole (one or more pinctrl_ modules followed by the installer's exact module list), so a hand-written drop-in that resets MODULES on purpose is left alone. It rebuilds whether or not nvidia.conf exists, since the reset also dropped modules from other sources; fresh installs mark every migration complete, so only machines that had the old file rebuild. Like the other migrations that call it, it trusts limine-mkinitcpio's exit status, which stays 0 when a single kernel's build fails.

The comment in omarchy_hooks.conf that described the Surface file as the exception now states the rule: a drop-in sorting after it must append to MODULES, because it reads MODULES midway through sourcing to decide whether to drop the kms hook.

install/hardware/apple/fix-spi-keyboard.sh has the same MODULES= shape. It is left as it is: macbook_spi_modules.conf sorts before nvidia.conf and omarchy_hooks.conf, so it collides with nothing Omarchy writes today.

Fixes #7111

surface_device_modules.conf sorts after nvidia.conf in mkinitcpio's drop-in order, so writing MODULES=(...) dropped nvidia, nvidia_modeset, nvidia_uvm and nvidia_drm from the initramfs on every Surface with an NVIDIA GPU, along with any module an earlier drop-in or the main config listed.

A migration repairs the file on existing installs and rebuilds the initramfs once per machine. It matches only the file the installer wrote, whole, so a hand-written drop-in that resets MODULES on purpose is left alone. It rebuilds whether or not nvidia.conf is present, since the reset also dropped modules from other sources; fresh installs mark every migration complete, so only machines that had the old file rebuild.

Fixes #7111

Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High risk] Changes how kernel modules are loaded during boot.

The PR appears safe to merge, with non-blocking improvements to shared rebuild locking and retry tests.

Findings

  1. P2 Rebuilds can run twice ▶
  2. P2 Retry test never fails ▶

Summary

The Surface keyboard installer now appends to MODULES instead of replacing earlier entries. A migration repairs matching existing files and rebuilds the boot images.

  • The migration keeps custom files unchanged and records a machine-wide completion marker.
  • The tests cover module preservation, repeat runs, multiple pinctrl modules, and custom files.
  • Non-blocking improvements: lock the shared rebuild and test an actual failed rebuild.
  • omarchybot explicitly acknowledges that limine-mkinitcpio can return success when an individual kernel build fails. That known limitation is not reported again.

Reviews (1) · Last reviewed commit: "Append the Surface keyboard modules inst..." · Reviewed by Greptile

Comment thread migrations/1791403252.sh
Comment on lines +23 to +27
[[ ! -e $rebuild_marker ]] || exit 0
omarchy-cmd-present limine-mkinitcpio || exit 0

sudo limine-mkinitcpio
sudo install -Dm644 /dev/null "$rebuild_marker"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Rebuilds can run twice

Two users running omarchy-migrate together can both pass the shared marker check and call limine-mkinitcpio before either writes the marker. The marker prevents later runs, but not overlapping ones, so the expensive rebuild can run twice. Take a machine-wide lock and check the marker again inside it.

Knowledge Base Used: Migration framework

Comment on lines +111 to +116
rm -f "$marker"
: >"$calls"
run_migration
grep -Fxq 'limine-mkinitcpio' "$calls" || fail "the migration retries an interrupted rebuild"
! grep -q $'^sudo\tsed$' "$calls" || fail "a retried rebuild leaves the repaired file alone" "$(cat "$calls")"
pass "the migration retries an interrupted rebuild"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Retry test never fails

The test called “retries an interrupted rebuild” only deletes a marker from a successful run. The limine-mkinitcpio stub always succeeds, so the test would miss a change that records completion after a failed rebuild. Make the stub fail once, assert a nonzero exit and no marker, then retry successfully with the already-repaired file.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Two notes:

Blocking: migration filename collision. migrations/1791403252.sh is also added by #14551 (OPR priority) and #14552 (dictation). Whichever lands second overwrites the other. This needs a fresh timestamp, and the rebuild marker path /var/lib/omarchy/migrations/1791403252 (plus the test's $ROOT/migrations/1791403252.sh) needs to follow the new name.

Overlap: #8151 ("Preserve existing initramfs modules on Surface devices") is still open for the same issue (#7111). This version adds the migration and the omarchy_hooks.conf comment update, so it looks more complete, but the two should be consolidated.

@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed by Claude Opus 5.5, with a second opinion from Codex Medium. Both were source reviews against quattro at 51bfd1d, and nothing was run on a worker, for the reason below.

This competes with #8151, which is older and fixes #7111 with the same one-line MODULES+= change to install/hardware/fix-surface-keyboard.sh. When two fixes are this close, the older one is the one to land, and #8151 has no defect that would change that. Codex reached the same choice on its own, though its independence is not guaranteed. So this pull request will not be brought to ready, and its improvement moves to #8151.

What this one adds is the repair for existing installs. #8151 changes what the installer writes from now on, but a Surface that already has the old MODULES=(...) drop-in keeps losing its NVIDIA modules until that file is rewritten and the initramfs rebuilt. The migration here does that, and it touches only a file that matches what the installer wrote. That improvement has been handed to #8151, to be added there.

It cannot be carried over as it stands, for three reasons:

  • migrations/1791403252.sh already exists on quattro, as the migration that puts the Omarchy package repository ahead of Arch's. That is why this branch conflicts. Machines that already ran that migration have it recorded as done, so the Surface repair needs a fresh timestamp, and its rebuild marker and test have to use the new name too.
  • test/shell.d/surface-hardware-test.sh:66 on quattro still expects MODULES=(...). This branch does not update it, and Preserve existing initramfs modules on Surface devices #8151 does.
  • test/shell.d/surface-keyboard-modules-test.sh does not stub the omarchy-hw-x86 gate that quattro now has. It also requires thunderbolt to come out of a thunderbolt_module.conf that depends on the host, so it fails on an ARM machine or a host without that module.

This now waits on the maintainer: #8151 is the fix to merge, with the migration added to it, and this one can then be closed.

omarchybot added a commit to jovial-liu/omarchy that referenced this pull request Oct 16, 2026
The installer now appends, but a Surface installed before this keeps the MODULES=(...) drop-in, which sorts after nvidia.conf and drops its modules from every initramfs. The migration rewrites only a file that is exactly what the installer wrote, then rebuilds once per machine, with a marker so another user skips a finished rebuild and an interrupted one is retried. Carried over from omacom#14541 under a fresh timestamp, since 1791403252 is already taken on quattro.

The omarchy_hooks.conf comment now states the rule instead of describing the old Surface file as the exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix-surface-keyboard.sh resets MODULES instead of appending, stripping NVIDIA early KMS on Surface devices

2 participants