I made a dual-bootable NixBSD (NixOS + FreeBSD) image

demo

I’ve been working on getting NixBSD to boot alongside NixOS on a shared ZFS pool. The result is a <2GB disk image you can try in QEMU or virt-manager.

What works:

  • GRUB chainloads FreeBSD’s bootloader
  • Both systems share a ZFS pool
  • Everything is defined in a single Nix flake
  • Fully reproducible builds (some dependencies are now cached on Cachix)

Planned:

  • Support native compilation of NixBSD (currently cross-compiled on Linux)
  • Many shortcuts were taken to get this working, needs lots of cleanup
  • Add a semi-automated installer like nixos-wizard

Try it:

qemu-system-x86_64 -enable-kvm -m 2048 \
  -bios /usr/share/ovmf/OVMF.fd \
  -drive file=nixos.root.img,format=raw

Login: nixos/nixos or root/toor

The hardest parts were getting mounts working at boot, making the bootloader setup idempotent, and debugging early init. This disk image could potentially work on a USB stick with a bit more work.

This is very much experimental. My goal is to eventually produce a proper NixBSD installation ISO and consolidate all configuration into one repository while still consuming upstream NixBSD as a flake.

Download: Release Build 1 · jonhermansen/nixbsd-demo · GitHub

Feel free to leave feedback here or on GitHub! Thanks!

16 Likes

as I said on HN, and also in the Asterinas NixOS (Linux alternative with Nix userland) thread, I think no more Linux monopoly is the future — we’ll be playing different kernels against each other, restoring OS competition and speeding back up the pace of OS innovation.

7 Likes

amazing work @jonhermansen! i’m really glad to see you on discourse now :tada:

3 Likes

The word “NixBSD” causes a lot of excitement, but I feel like it’s a little weakly defined here.

Do you run a NixOS-like userland with simply the kernel switched to a BSD kernel?

Edit: I read your HN comment that NixBSD is actually a well-defined project with more activity and maturity than when I last checked it. I apologise for the lack of research before asking this question!

Because from what I associate with a BSD is:

  • Unified development: The kernel and userland are developed together, tested together, released together. This is philosophically similar to NixOS’s approach of treating the entire system as a coherent, reproducible unit.
  • Ports/packages as secondary: In FreeBSD/OpenBSD, the base system is the “real” OS; ports are add-ons. NixOS is a byproduct of nixpkgs and doesn’t exist independently of it, so would a NixBSD be more like NixOS, or more like FreeBSD in this regard?
  • Configuration simplicity: /etc/rc.conf as the single source of truth for system configuration echoes NixOS’s configuration.nix, though declaratively rather than imperatively. I think this is where NixOS and BSD align the most, but also where I’d expect a remake of NixOS’es options to seek the simplicity of BSDs.

Regardless of your interpretation, I’m very happy to see someone work with these concepts!

1 Like