Repository navigation
Conversation
scottjones
left a comment
There was a problem hiding this comment.
Reviewed this against #343, which adds a second device-tree SoC detector. Ran both on an M2 Max (apple,j414c, t6021) and against stubbed trees for the IDs where the two tables disagree.
Your table is the better one, and it is the part I would keep. It has t6032 (M3 Ultra), which #343 omits entirely — so a Mac Studio M3 Ultra fails detection there outright. And keeping t6040/t6041 as unconfirmed-compatible rather than guessing, with the pinned Asahi SoC table and DTS tree cited in the description, is the right call; #343 claims those plus t6050/t6051 as m4 with no source. Refusing to state what you cannot evidence is worth more here than coverage.
bug: the command ignores OMARCHY_APPLE_COMPATIBLE, so nothing else can stub it.
The production entry point hardcodes the path:
--key) omarchy_apple_silicon_generation_parse "/proc/device-tree/compatible" "key" ;;
--diagnose) omarchy_apple_silicon_generation_parse "/proc/device-tree/compatible" "diagnose" ;;I found this the hard way: I pointed OMARCHY_APPLE_COMPATIBLE at five different stub trees and got m2-max every time, because it was reading this machine's real device tree and ignoring me. I had to source the file and call the parser directly, the way your own tests do, to get real answers.
That is a convention break with real consequences. omarchy-hw-apple-silicon in #331 takes OMARCHY_APPLE_COMPATIBLE; omarchy-hw-apple-soc in #343 takes it; omarchy-hw-dp-altmode in #289 takes OMARCHY_DEVICE_TREE. A hidden identity command exists so other code can branch on it, and other code's tests then need to stub it. As written, they cannot — only this file's own tests can, and only by sourcing it. Reading the path from ${OMARCHY_APPLE_COMPATIBLE:-/proc/device-tree/compatible} costs one line and makes the command testable from outside.
suggestion: 197 lines and ten distinct failure codes is a lot of parser for a file the kernel generates. The conflicting-compatible and ambiguous-compatible cases are legitimate — two different SoC selectors in one tree is a real thing to refuse. But non-ascii-compatible, truncated-record via an od byte inspection, and the per-byte printf '%d' escape loop defend against a malformed device tree on a machine that would not have booted. It is also the file most likely to confuse the next reader. Not blocking, and I would rather have this than the opposite failure, but it is worth asking which of those ten states can actually occur.
The duplication
Three device-tree detectors are now in flight:
| PR | command | does |
|---|---|---|
| #331 (@malik-na) | omarchy-hw-apple-silicon |
boolean: is this Apple Silicon |
| this | omarchy-hw-apple-silicon-generation |
device tree -> granular (m2-max) |
| #343 (@staccDOTsol) | omarchy-hw-apple-soc |
device tree -> m1..m4 + codename + --gpu |
Different filenames, so git will not stop any of them and all three could land. My read is that #343 has the better shape and this PR has the better table. #343 is env-stubbable, 96 lines against 197, and has a --gpu check that asks whether the Asahi GPU driver is actually bound rather than inferring capability from generation — I verified that one on hardware and it is correct. Keying decisions off the binding means a generation table cannot go stale underneath them.
The merge of the two is the command I would want: #343's interface with your table and your sourcing discipline.
Granularity is a genuine decision someone should make deliberately rather than by merge order — m2 plus --codename versus m2-max. Both are defensible; shipping both means callers pick arbitrarily. Worth you and @staccDOTsol settling it between you, and #331's boolean is the third piece both of these arguably should build on.
I am marking this changes-requested for the env-override line, which is a small concrete fix. The duplication question is not mine to decide alone and should not block you on its own.
|
The existing blocker remains: the executable entrypoint still hardcodes /proc/device-tree/compatible. Use OMARCHY_APPLE_COMPATIBLE so callers can stub it, then reconcile the public shape with #343 before either detector lands. |
|
Tested fix for the blocker in #326 (comment) — the hardcoded What changed The entry point now resolves the source once and honours compatible=${OMARCHY_APPLE_COMPATIBLE:-/proc/device-tree/compatible}Branch: Worth flagging separately The focused test currently asserts the hardcoded behaviour and uses a different variable name: if overridden=$(OMARCHY_DEVICE_TREE_COMPATIBLE="$fixture" ...)
...
[[ $direct_status == "$override_status" ]] || fail "executable ignores source environment override"
pass "executable hardcodes default source and rejects overrides"So the test locks in the opposite of what was requested. I rewrote that block to check that the override resolves Verification
Happy to open this as a PR against your branch, or cherry-pick |
|
Thanks @eXsoR65, this fixes the blocker. I checked it against What I ran:
Two small optional follow-ups, not blocking:
@CptPanko, happy for you to cherry-pick 9d231b9 onto your branch. That clears the hardcoded-path blocker from my side. |
|
Thanks — and you're right about the count. It is 29, not 25. My number came from a truncated tail of the run, not from counting; the suite was green either way but the figure was wrong. Both follow-ups are implemented, and I verified each one the way you did — by making it fail. 1. The default path is now pinned. The gap was real: the fallback branch only distinguishes "missing" from "readable", so any typo in the literal still produced env -u OMARCHY_APPLE_COMPATIBLE "$parser_bash" -c '"$1" --diagnose' ...
grep -Fqx 'source=/proc/device-tree/compatible' "$test_tmp/default-diag-err" ||
fail "unset override falls back to the live device tree path" ...Mutation-checked: changing the default to 2. New test builds a path containing a newline followed by State
One thing I did not act on, since it is your call rather than a fix: |
|
Thanks @eXsoR65, both follow-ups look good. I checked 91fc23e: still one commit on f2573a4, it merges cleanly onto current What I ran:
One small nit, not blocking: with On splitting: I'd keep it as one commit. Nobody has picked up 9d231b9 yet, so it's one cherry-pick either way. If you fix the nit, amend it in. On @CptPanko, 91fc23e is the one to cherry-pick now instead of 9d231b9. |
|
Nit fixed, and you were right about the cause — it was a regression I introduced with Reproduced first: Both comparisons now go through the quoted form: grep -Fqx "source=$(printf %q "$fixture")" "$stderr_file" || fail "diagnose reports source"
...
grep -Fqx "source=$(printf %q "$fixture")" "$test_tmp/override-diag-err" || fail "diagnose reports the overridden source" ...I added a comment above the first one so the next person does not simplify it back to Checked three TMPDIR values, 31
Kept it as one commit as you suggested, so @CptPanko — On |
Summary
Scope
This is identity detection only. It does not enable installation, change setup policy, or claim native M3/M4 support.
Mappings are grounded in the pinned Asahi SoC table and literal compatible records in the pinned Asahi Linux Apple DTS tree.
Testing
test/shell.d/apple-silicon-generation-test.sh(27 assertions under macOS Bash 3.2, Homebrew Bash, and Ubuntu 24.04)bin/omarchy commands --checkunder modern Bashbin/omarchy-*commandgit diff --checkThe aggregate suite remains bounded by existing macOS host/tooling incompatibilities; the changed focused suite and Linux run pass.