Skip to content

macos: port purefetch to macOS - #1

Merged
ooonea merged 3 commits into
mainfrom
macos
Jul 23, 2026
Merged

macos: port purefetch to macOS#1
ooonea merged 3 commits into
mainfrom
macos

Conversation

@ooonea

@ooonea ooonea commented Jul 23, 2026

Copy link
Copy Markdown
Owner

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

ooonea added 3 commits July 23, 2026 22:26
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
@ooonea
ooonea merged commit 5edf361 into main Jul 23, 2026
4 checks passed
@ooonea
ooonea deleted the macos branch July 23, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant