Conversation
Move the Linux syscall shims to src/sys/linux.rs behind a thin sys/mod.rs dispatcher, and lift hostname() and the parent-chain ppid/comm lookup out of main/detect into the platform layer: those are exactly the points where a macOS implementation will differ. src/sys/darwin.rs is a placeholder for the upcoming port. No behavior change on Linux. Assisted-by: Claude Code
New darwin platform layer (src/sys/darwin.rs): extern "C" bindings straight to libSystem — statfs ($INODE64 on x86_64), sysctlbyname, kern.boottime, vm.swapusage, host_statistics64 memory stats, proc_pidinfo for the parent-chain walks, gethostname, isatty/TIOCGWINSZ — plus the CoreGraphics active-display list. Raw syscalls are not a stable ABI on macOS; libSystem is already linked by std, so the zero-external-dependency rule holds. Every detection module gains a target_os=macos path: OS from SystemVersion.plist (+codename map), Kernel "Darwin x.y.z", CPU brand string (+Intel max freq), Memory/Swap via mach/sysctl matching vm_stat, Disk on the shared APFS container (used = total - available), Host product-name via ioreg with hw.model fallback, GPU from the IOAccelerator registry (+core count), DE Aqua / WM Quartz Compositor, brew/brew-cask/macports counts, pmset battery, TERM_PROGRAM(+_VERSION) terminals. Apple logo asset (fastfetch art, COLORS format) wired as 'macos' with aliases. CI: real build+test+run jobs on macos-latest (arm64) and macos-26-intel with output assertions; clippy runs there because the ubuntu job never compiles the darwin cfg paths. Flake: +aarch64-darwin/x86_64-darwin, platforms += darwin. Assisted-by: Claude Code
Adversarial-review follow-ups: ioctl request is c_ulong (not u64 — same ABI on 64-bit, wrong type); the statfs $INODE64 suffix now keys on not(target_arch=aarch64) exactly like the libc crate, so a future non-arm64 darwin arch cannot silently link the 32-bit-inode symbol; the VmStatistics64 layout comment claimed xnu pack(4) — it is natural aligned(8) layout, reworded; the ZFS pool helpers in detect/disk.rs are Linux-gated so no dead /proc code ships in the macOS binary; the MSRV job also compile-checks aarch64-apple-darwin; stale src/sys.rs path in a CI comment. Assisted-by: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port to macOS: darwin platform layer via direct libSystem FFI (no libc crate — zero external dependencies holds), per-module target_os=macos detection paths, Apple logo, real macOS CI on arm64 + Intel runners with output assertions, darwin systems in the flake.
Merging after CI is green on both macOS runners.
🤖 Generated with Claude Code