Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions bin/omarchy-hw-bcm43xx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# omarchy:summary=Detect Broadcom BCM4360/BCM4331 Wi-Fi that needs the wl driver.
# omarchy:hidden=true

pci_devices_path="${OMARCHY_PCI_DEVICES_PATH:-/sys/bus/pci/devices}"

shopt -s nullglob

for device in "$pci_devices_path"/*; do
[[ -r $device/vendor && -r $device/device ]] || continue
[[ $(<"$device/vendor") == "0x14e4" ]] || continue
case $(<"$device/device") in
0x43a0 | 0x4331) exit 0 ;;
esac
done

exit 1
21 changes: 21 additions & 0 deletions bin/omarchy-hw-t2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# omarchy:summary=Detect whether the computer has an Apple T2 security chip.
# omarchy:hidden=true

# Vendor 106b (Apple), devices 1801/1802. Read cached sysfs IDs rather than
# lspci, which reads PCI config space and can wake suspended devices.

pci_devices_path="${OMARCHY_PCI_DEVICES_PATH:-/sys/bus/pci/devices}"

shopt -s nullglob

for device in "$pci_devices_path"/*; do
[[ -r $device/vendor && -r $device/device ]] || continue
[[ $(<"$device/vendor") == "0x106b" ]] || continue
case $(<"$device/device") in
0x1801 | 0x1802) exit 0 ;;
esac
done

exit 1
5 changes: 2 additions & 3 deletions install/hardware/apple/fix-t2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Detect T2 MacBook models using PCI IDs
# Vendor: 106b (Apple), Device IDs: 1801 or 1802 (T2 Security Chip)
if lspci -nn | grep "106b:180[12]" >/dev/null; then
# Detect T2 MacBook models using the T2 PCI IDs (Apple 106b:1801/1802).
if omarchy-hw-t2; then
echo "Detected MacBook with T2 chip. Installing support items..."

omarchy-pkg-add \
Expand Down
4 changes: 1 addition & 3 deletions install/hardware/fix-bcm43xx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# - BCM4360 (2013–2015 MacBooks)
# - BCM4331 (2012, early 2013 MacBooks)

pci_info=$(lspci -nn)

if (echo "$pci_info" | grep -q "14e4:43a0" || echo "$pci_info" | grep -q "14e4:4331"); then
if omarchy-hw-bcm43xx; then
echo "BCM4360 / BCM4331 detected"
omarchy-pkg-add broadcom-wl-dkms
fi
4 changes: 3 additions & 1 deletion install/hardware/nvidia.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
if lspci | grep -qi 'nvidia'; then
# omarchy-hw-nvidia reads sysfs IDs. lspci would walk PCI config space and
# wake a runtime-suspended GPU, and Hyprland already uses the same helper.
if omarchy-hw-nvidia; then
if omarchy-hw-nvidia-gsp; then
PACKAGES=(nvidia-open-dkms nvidia-utils lib32-nvidia-utils libva-nvidia-driver)
elif omarchy-hw-nvidia-without-gsp; then
Expand Down
2 changes: 1 addition & 1 deletion install/hardware/pacman.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hardware-specific pacman repository extensions that must survive the final
# pacman.conf restore.
if lspci -nn | grep "106b:180[12]" >/dev/null; then
if omarchy-hw-t2; then
if ! grep -q '^\[arch-mact2\]' /etc/pacman.conf; then
cat >> /etc/pacman.conf <<'EOF'

Expand Down
31 changes: 22 additions & 9 deletions install/hardware/vulkan.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
# Install Vulkan drivers matching detected GPU hardware
# (NVIDIA Vulkan is handled by nvidia.sh via nvidia-utils)
#
# Walk sysfs the way omarchy-hw-nvidia does. lspci reads PCI config space and
# resumes runtime-suspended GPUs; three greps used to do that once per vendor.

declare -A VULKAN_DRIVERS=(
[Intel]=vulkan-intel
[AMD]=vulkan-radeon
[Apple]=vulkan-asahi
)
pci_devices_path="${OMARCHY_PCI_DEVICES_PATH:-/sys/bus/pci/devices}"

PACKAGES=()

for vendor in "${!VULKAN_DRIVERS[@]}"; do
if lspci | grep -iE "(VGA|Display).*$vendor" > /dev/null; then
PACKAGES+=("${VULKAN_DRIVERS[$vendor]}")
fi
add_vulkan_pkg() {
local pkg=$1
local existing
for existing in "${PACKAGES[@]+"${PACKAGES[@]}"}"; do
[[ $existing == "$pkg" ]] && return
done
PACKAGES+=("$pkg")
}

shopt -s nullglob
for device in "$pci_devices_path"/*; do
[[ -r $device/vendor && -r $device/class ]] || continue
[[ $(<"$device/class") == 0x03* ]] || continue
case $(<"$device/vendor") in
0x8086) add_vulkan_pkg vulkan-intel ;;
0x1002) add_vulkan_pkg vulkan-radeon ;;
0x106b) add_vulkan_pkg vulkan-asahi ;;
esac
done

if (( ${#PACKAGES[@]} > 0 )); then
Expand Down
51 changes: 51 additions & 0 deletions test/shell.d/hw-bcm43xx-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

write_pci() {
rm -rf "$tmp/devices"
mkdir -p "$tmp/devices"
local index=0 spec slot
for spec in "$@"; do
slot=$(printf '0000:%02x:00.0' "$index")
mkdir -p "$tmp/devices/$slot"
printf '%s\n' "${spec%%:*}" >"$tmp/devices/$slot/vendor"
printf '%s\n' "$(cut -d: -f2 <<<"$spec")" >"$tmp/devices/$slot/device"
index=$((index + 1))
done
}

hw() {
OMARCHY_PCI_DEVICES_PATH="$tmp/devices" "$ROOT/bin/omarchy-hw-bcm43xx"
}

write_pci 0x14e4:0x43a0
hw || fail "BCM4360 is detected"
pass "BCM4360 is detected from sysfs"

write_pci 0x14e4:0x4331
hw || fail "BCM4331 is detected"
pass "BCM4331 is detected from sysfs"

write_pci 0x14e4:0x43ba
hw && fail "a brcmfmac part is not the wl driver"
pass "newer Broadcom Wi-Fi is left to brcmfmac"

write_pci 0x8086:0x43a0
hw && fail "the device ID under a different vendor is rejected"
pass "matching device IDs under unrelated vendors are rejected"

write_pci
hw && fail "empty PCI space is not bcm43xx"
pass "a machine with no PCI devices is not bcm43xx"

grep -Fq 'omarchy-hw-bcm43xx' "$ROOT/install/hardware/fix-bcm43xx.sh" ||
fail "Broadcom wl install uses omarchy-hw-bcm43xx"
! grep -q lspci "$ROOT/install/hardware/fix-bcm43xx.sh" ||
fail "Broadcom wl install no longer greps lspci twice"
pass "Broadcom wl install does not parse a full lspci dump"
56 changes: 56 additions & 0 deletions test/shell.d/hw-t2-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

write_pci() {
rm -rf "$tmp/devices"
mkdir -p "$tmp/devices"
local index=0 spec slot
for spec in "$@"; do
slot=$(printf '0000:%02x:00.0' "$index")
mkdir -p "$tmp/devices/$slot"
printf '%s\n' "${spec%%:*}" >"$tmp/devices/$slot/vendor"
printf '%s\n' "$(cut -d: -f2 <<<"$spec")" >"$tmp/devices/$slot/device"
printf '%s\n' "${spec##*:}" >"$tmp/devices/$slot/class"
index=$((index + 1))
done
}

hw_t2() {
OMARCHY_PCI_DEVICES_PATH="$tmp/devices" "$ROOT/bin/omarchy-hw-t2"
}

write_pci 0x106b:0x1801:0x068000
hw_t2 || fail "T2 chip 1801 is detected"
pass "Apple T2 device 1801 is detected from sysfs"

write_pci 0x106b:0x1802:0x068000
hw_t2 || fail "T2 chip 1802 is detected"
pass "Apple T2 device 1802 is detected from sysfs"

write_pci 0x106b:0x1803:0x068000
hw_t2 && fail "a different Apple PCI id is not a T2 chip"
pass "other Apple PCI functions are not treated as T2"

write_pci 0x8086:0x1801:0x068000
hw_t2 && fail "the device ID under a different vendor is rejected"
pass "matching device IDs under unrelated vendors are rejected"

write_pci
hw_t2 && fail "empty PCI space is not T2"
pass "a machine with no PCI devices is not T2"

grep -Fq 'omarchy-hw-t2' "$ROOT/install/hardware/apple/fix-t2.sh" ||
fail "T2 package install uses omarchy-hw-t2"
grep -Fq 'omarchy-hw-t2' "$ROOT/install/hardware/pacman.sh" ||
fail "the arch-mact2 repo drop-in uses omarchy-hw-t2"
! grep -q 'lspci' "$ROOT/install/hardware/apple/fix-t2.sh" ||
fail "T2 package install no longer greps lspci"
! grep -q 'lspci' "$ROOT/install/hardware/pacman.sh" ||
fail "the arch-mact2 repo drop-in no longer greps lspci"
pass "T2 install paths share one sysfs helper"
67 changes: 67 additions & 0 deletions test/shell.d/nvidia-hw-detect-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/bin" "$tmp/devices/0000:01:00.0"

# Execute the real installer with only its absolute configuration destination
# relocated. Package installation and PCI config-space access are stubbed.
sed "s|/etc/|$tmp/etc/|g" "$ROOT/install/hardware/nvidia.sh" >"$tmp/nvidia.sh"
cat >"$tmp/bin/omarchy-pkg-add" <<'SH'
#!/bin/bash
printf '%s\n' "$@" >>"$OMARCHY_TEST_NVIDIA_PKGS"
SH
cat >"$tmp/bin/lspci" <<'SH'
#!/bin/bash
echo called >>"$OMARCHY_TEST_NVIDIA_LSPCI"
echo 'NVIDIA VGA controller'
SH
chmod +x "$tmp/bin/"*

run_layout() {
local vendor=$1 device=$2 class=$3
printf '%s\n' "$vendor" >"$tmp/devices/0000:01:00.0/vendor"
printf '%s\n' "$device" >"$tmp/devices/0000:01:00.0/device"
printf '%s\n' "$class" >"$tmp/devices/0000:01:00.0/class"
rm -rf "$tmp/etc"
: >"$tmp/pkgs"
: >"$tmp/lspci"
OMARCHY_PCI_DEVICES_PATH="$tmp/devices" \
OMARCHY_TEST_NVIDIA_PKGS="$tmp/pkgs" OMARCHY_TEST_NVIDIA_LSPCI="$tmp/lspci" \
PATH="$tmp/bin:$ROOT/bin:$PATH" \
bash -e "$tmp/nvidia.sh" >"$tmp/output"
[[ ! -s $tmp/lspci ]] || fail "installer never queries PCI config space"
}

run_layout 0x8086 0x1e04 0x030000
[[ ! -s $tmp/pkgs && ! -s $tmp/output && ! -e $tmp/etc ]] ||
fail "non-NVIDIA displays skip the driver block"
pass "non-NVIDIA displays do not enter NVIDIA installation"

run_layout 0x10de 0x1e04 0x040300
[[ ! -s $tmp/pkgs && ! -s $tmp/output && ! -e $tmp/etc ]] ||
fail "NVIDIA audio functions skip the driver block"
pass "NVIDIA audio functions do not install graphics drivers"

run_layout 0x10de 0x1e04 0x030000
[[ $(cat "$tmp/pkgs") == $'nvidia-open-dkms\nnvidia-utils\nlib32-nvidia-utils\nlibva-nvidia-driver' ]] ||
fail "GSP displays install the open driver package set"
[[ $(cat "$tmp/etc/modprobe.d/nvidia.conf") == 'options nvidia_drm modeset=1' ]] ||
fail "NVIDIA KMS config is written"
[[ $(cat "$tmp/etc/mkinitcpio.conf.d/nvidia.conf") == 'MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)' ]] ||
fail "NVIDIA early-loading config is written"
pass "GSP displays install the open driver and its configuration"

run_layout 0x10de 0x1b80 0x030000
[[ $(cat "$tmp/pkgs") == $'nvidia-580xx-dkms\nnvidia-580xx-utils\nlib32-nvidia-580xx-utils' ]] ||
fail "pre-GSP displays install the 580xx package set"
pass "pre-GSP displays install the 580xx driver"

run_layout 0x10de 0x1180 0x030000
[[ ! -s $tmp/pkgs && ! -e $tmp/etc ]] || fail "unsupported GPUs install no packages"
grep -Fq 'No compatible driver' "$tmp/output" || fail "unsupported GPU reports the driver limitation"
pass "unsupported NVIDIA displays report the driver limitation"
74 changes: 74 additions & 0 deletions test/shell.d/vulkan-sysfs-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

write_pci() {
rm -rf "$tmp/devices"
mkdir -p "$tmp/devices"
local index=0 spec slot
for spec in "$@"; do
slot=$(printf '0000:%02x:00.0' "$index")
mkdir -p "$tmp/devices/$slot"
printf '%s\n' "${spec%%:*}" >"$tmp/devices/$slot/vendor"
printf '%s\n' "${spec##*:}" >"$tmp/devices/$slot/class"
index=$((index + 1))
done
}

stub_bin="$tmp/bin"
mkdir -p "$stub_bin"
cat >"$stub_bin/omarchy-pkg-add" <<'SH'
#!/bin/bash
printf '%s\n' "$@" >>"$OMARCHY_TEST_VULKAN_PKGS"
SH
chmod +x "$stub_bin/omarchy-pkg-add"

run_vulkan() {
: >"$tmp/pkgs"
OMARCHY_PCI_DEVICES_PATH="$tmp/devices" \
OMARCHY_TEST_VULKAN_PKGS="$tmp/pkgs" \
PATH="$stub_bin:$PATH" \
bash "$ROOT/install/hardware/vulkan.sh"
}

write_pci 0x8086:0x030000
run_vulkan
grep -Fxq 'vulkan-intel' "$tmp/pkgs" || fail "Intel display gets vulkan-intel" "$(cat "$tmp/pkgs")"
pass "Intel display installs vulkan-intel from sysfs"

write_pci 0x1002:0x030000 0x10de:0x030200
run_vulkan
grep -Fxq 'vulkan-radeon' "$tmp/pkgs" || fail "AMD iGPU gets vulkan-radeon on a hybrid machine"
! grep -q nvidia "$tmp/pkgs" || fail "NVIDIA Vulkan stays with nvidia.sh"
pass "hybrid AMD+NVIDIA only adds vulkan-radeon here"

write_pci 0x8086:0x040300
run_vulkan
[[ ! -s $tmp/pkgs ]] || fail "an Intel audio function is not a GPU" "$(cat "$tmp/pkgs")"
pass "non-display PCI functions do not pull Vulkan drivers"

write_pci 0x106b:0x030000
run_vulkan
[[ $(cat "$tmp/pkgs") == "vulkan-asahi" ]] || fail "Apple display gets its Vulkan package"
pass "Apple display functions install vulkan-asahi"

write_pci 0x106b:0x000000 0x8086:0x030000 0x1002:0x030000
run_vulkan
[[ $(cat "$tmp/pkgs") == $'vulkan-intel\nvulkan-radeon' ]] || fail "T2 non-display function does not add an Apple GPU driver"
pass "T2 non-display functions are excluded from GPU driver selection"

write_pci 0x8086:0x030200 0x1002:0x030100
run_vulkan
[[ $(cat "$tmp/pkgs") == $'vulkan-intel\nvulkan-radeon' ]] || fail "3D and XGA display classes are included"
pass "3D and XGA display classes receive their vendor drivers"

grep -Fq 'OMARCHY_PCI_DEVICES_PATH' "$ROOT/install/hardware/vulkan.sh" ||
fail "Vulkan install reads the same sysfs override as omarchy-hw-nvidia"
! grep -E '^[^#]*lspci' "$ROOT/install/hardware/vulkan.sh" ||
fail "Vulkan install no longer shells out to lspci"
pass "Vulkan install does not wake GPUs via lspci"