ZMK.OS(5)

✨ zmk.OS(5) β€” the manual page, bestie edition ✨

okay so real talk, this is the local manual page for the OS module in zmk β€” it's section 5 of the manual, so you're in the right place, you didn't take a wrong turn at the filesystem, we love that for you πŸ’…


🌸 NAME 🌸

OS β€” the module that hands you all the deets about the operating system that's out here running zmk πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

so to actually use it, you drop this in your makefile situation:

include z.mk

$(eval $(call ZMK.Import,OS))

and boom, that's it, you're in 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

The OS module is literally your little informant β€” it provides info about the operating system that's executing zmk. It's giving "I know a guy". You use it to tailor your behavior and to account for the differences between all the UNIX flavours out there, because they are not the same and pretending they are is how you end up crying at 3am 😭


🌈 TARGETS 🌈

This module does not provide any targets.

(yeah, zero, none, nada β€” it's not that kind of module, it's purely here to spill the tea β˜•)


πŸ’œ VARIABLES πŸ’œ

This module provides the following variables. Obsessed with them, honestly.

⭐ OS.Kernel ⭐

Identifier of the operating system kernel. Basically "which kernel are we on, bestie?"

Known values are listed right here, no gatekeeping:

  • Darwin β€” The MacOS kernel
  • FreeBSD β€” The FreeBSD kernel
  • GNU/kFreeBSD β€” The FreeBSD kernel with GNU userspace
  • GNU β€” The Hurd kernel
  • Linux β€” All Linux kernel
  • NetBSD β€” The NetBSD kernel
  • OpenBSD β€” The OpenBSD kernel
  • SunOS β€” The Solaris kernel
  • Windows_NT β€” The Windows kernel
  • Haiku β€” The Haiku kernel

🧚 OS.ImageFormat 🧚

Identifier or the application image format used. (yes, the original says "or", not "of", we keep it exactly as it is, we do not edit the ancestors πŸ’€)

The values, served fresh:

  • ELF β€” Used by most UNIX-like systems, except Darwin
  • Mach-O β€” Used by MacOS
  • PE β€” Used by Windows
  • MZ β€” Used by DOS
heads up bestie: due to cross-compiling it is more useful to look at Toolchain.ImageFormat instead. Like, genuinely, that's the one you want. OS.ImageFormat is lowkey the wrong vibe check when you're cross-compiling πŸ™ˆ

πŸ“ IMPLEMENTATION NOTES πŸ“

The way this actually works is kinda iconic:

  • Windows is detected by the presence and specific value of the OS environment variable.
  • All other kernels are identified by invoking uname -s.

periodt. that's the whole trick πŸ‘‘


πŸ‘‘ HISTORY πŸ‘‘

The OS module first appeared in zmk 0.1 β€” a real OG, been here since day one, main character energy from the start 🌟


πŸ’– AUTHORS πŸ’–

Zygmunt Krynicki <me@zygoon.pl> β€” thank you for your service, we salute you 🫑


and that's the whole page, no notes, you ate that πŸ’…

this was brought to you by zmk 0.5.1, dated May 3, 2020, and it's the zmk.OS(5) page so you know exactly where to find it again πŸŽ€βœ¨ bye bestie, go write some portable makefiles πŸ¦‹