NyxOS, rebuilt from scratch in Haskell — a freestanding 64-bit kernel that boots on bare metal
Part of the NyxOS family — the same OS, rebuilt from zero in a different language each time. This is the Haskell cut, compiled with GHC.
Haskell is the hardest of the family: it is lazy and garbage-collected, and its runtime system (the STG machine, the heap, the scheduler) is enormous. The trick here is to skip the runtime entirely. The kernel is written so GHC compiles it, at -O2, to a straight-line native loop — the counters live in registers, the banner is a static byte table, and the only outside calls are an unsafe foreign import that stores one VGA cell. That compiled code touches its runtime in only two places: one stack-limit check (against register r15) and the return address on the STG stack. So a ten-line assembly stub (hs_boot.s) sets r15 = 0 — every check passes, so the runtime's overflow/GC path is never reached — points the STG stack at a buffer whose top returns into a halt, and jumps straight into the module's entry. No RTS, no hs_init, no GC is linked at all.
NyxOS-Haskell booting in QEMU (GRUB → long mode → GHC native code, no runtime) on the VGA text buffer
Why Haskell: it has been taken to bare metal before — House and the HaLVM ran Haskell as an operating system — so a runtime-free GHC kernel belongs in the family.
Needs ghc, gcc, nasm, ld, grub-mkrescue + xorriso, and qemu.
make # -> nyxos-haskell.iso (64-bit ELF booted via GRUB)
make run # boot the ISO in QEMUBecause the kernel is a 64-bit ELF, it boots from a GRUB ISO (qemu -cdrom) rather than qemu -kernel.
kernel.hs— the freestanding Haskell kernel; a no-allocation loop that stores VGA cells via anunsafeFFI imporths_boot.s— sets up the minimal STG state (r15/Sp) and jumps into the module entry, bypassing the runtimehs_shim.c— the VGA store plus the few ghc-prim data symbols the compiled code address-loadsboot64.asm— Multiboot header + the 32-bit → long-mode trampoline that callskmainlinker64.ld— links the 64-bit kernel at 1 MiB, Multiboot header firstgrub.cfg/Makefile— ISO packaging and boot
Early — it boots and paints the screen. Next up: a GDT/IDT, interrupts, and a VGA console.