machine-uid
Get the OS-native machine ID in Rust without root permission
Repository Health
Technical Analysis
machine-uid is a small Rust crate for reading a unique, OS-native machine identifier without requiring root or administrator privileges. It exposes a single machine_uid::get() function that reads the appropriate platform source — systemd’s machine-id on Linux, /etc/hostid or kenv on BSD, gethostuuid(3) on macOS, the MachineGuid registry key on Windows, and gethostid(3C) on illumos.
Because it normalizes these disparate platform mechanisms behind one API, it’s commonly used for license binding, device fingerprinting, telemetry deduplication, and any scenario needing a stable per-machine identifier across supported operating systems.
What You Get
- A single
machine_uid::get() -> Result<String>function usable across Linux, BSD, macOS, Windows, and illumos - Linux/systemd support via
/var/lib/dbus/machine-idor/etc/machine-id - BSD support via
/etc/hostidorkenv -q smbios.system.uuid - macOS support via the native
gethostuuid(3)syscall (no shelling out toioreg) - Windows support via the registry
MachineGuidkey, and illumos support viagethostid(3C)
Common Use Cases
- Binding a software license or activation key to a specific machine
- Generating a stable per-device identifier for telemetry or analytics deduplication
- Device fingerprinting for fraud detection or session anomaly checks
- Distinguishing machines in fleet-management or configuration-management tooling
Under The Hood
Architecture - The entire crate lives in a single src/lib.rs, organized as a get() entry point that dispatches via #[cfg(...)] conditional compilation to one of several platform-specific implementations bundled in the same file: reading /etc/machine-id on Linux, shelling out to or reading files for BSD, calling gethostuuid(3) directly on macOS (a recent change replacing a prior ioreg subprocess call), querying the Windows registry via windows-registry/windows-sys, and calling gethostid(3C) on illumos via libc. Platform selection happens entirely at compile time, so the compiled binary only contains the code path for its target OS.
Tech Stack - Pure Rust with target-conditional dependencies: windows-sys and windows-registry only pulled in for Windows builds, and libc only for macOS/illumos builds — Linux and BSD builds have zero external dependencies. The crate has moved away from a bundled C dependency and bindgen in recent releases in favor of native windows-registry bindings, reducing build complexity.
Code Quality - Test coverage lives in tests/tests.rs plus a tests/platform/ directory, exercising the platform-specific code paths. The crate has an active changelog documenting incremental fixes (cross-compilation issues, x86-on-x64 handling, dependency upgrades) tracked over 9 releases since 2018, indicating a maintainer who responds to real-world platform edge cases as they surface via GitHub Actions CI.
API Design - The public API is a single function, get(), returning a Result<String> — there is no configuration surface, builder, or platform-selection argument required from the caller. Getting started is a one-line call with no setup, and the crate’s doc comments and README both walk through the exact platform source used on each OS for transparency.
Used by 4 apps in this directory
Anarlog
Note Taking · AI Assistants · Productivity
Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.
GitButler
Developer Tools · Devops · AI Development
Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.
Jan
AI Assistants
Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.
OpenViking
Databases · AI Development
An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.