NixBSD
3 min read

Unofficial NixOS fork using a FreeBSD kernel. Brings reproducible, declarative configuration to BSD by replacing NixOS's Linux-specific modules with FreeBSD equivalents. Configuration mirrors NixOS syntax closely.

Quick Start

Try a VM without a local checkout:

sh
nix run 'github:nixos-bsd/nixbsd#extra.vm'
# Login: root:toor or bestie:toor

Repository Structure

NixBSD spans three repositories:

RepoPurpose
nixNix fork with FreeBSD build support and platform fixes
nixpkgsnixpkgs fork adding x86_64-freebsd platform and stdenv changes
nixbsdSystem modules (analogous to the nixos/ directory in nixpkgs)

FreeBSD source changes are minimal — patches are applied in nixpkgs rather than maintaining a separate kernel fork.

Building a VM

sh
# Pin the closure to prevent garbage collection (recommended — full build is 30+ GiB)
nix build .#base.vmClosureInfo --out-link .gcroots/vm

# Build the VM image
nix build .#base.vm

# Run it
result/bin/run-nixbsd-base-vm

Build Outputs

OutputDescription
toplevelFull system derivation; linked at /run/current-system
vmRunnable UEFI VM script (CoW, writable)
closureInfoClosure metadata to prevent GC
vmClosureInfoVM-specific closure info; keep this to avoid rebuilds

Build Tips

• First full build can take 8+ hours on fast hardware; save vmClosureInfo.
• Use --max-jobs 4 or lower if package checks fail intermittently under load.
• Replace nix with nom (nix-output-monitor) for readable build progress.

Configuration

NixBSD configurations follow NixOS module syntax. Place your config in configuration.nix inside a flake:

nix
# flake.nix
{
inputs = {
nixbsd.url = "github:nixos-bsd/nixbsd";
};

outputs = { self, nixbsd, ... }: {
nixbsdConfigurations.myhost = nixbsd.lib.nixbsdSystem {
system = "x86_64-freebsd";
modules = [ ./configuration.nix ];
};
};
}

nix
# configuration.nix
{ config, pkgs, lib, ... }: {
# Hostname
networking.hostName = "myhost";

# System packages
environment.systemPackages = with pkgs; [
git curl vim tmux
];

# Enable SSH
services.openssh = {
enable = true;
settings.PermitRootLogin = "no";
};

# ZFS (FreeBSD has native ZFS support)
boot.supportedFilesystems = [ "zfs" ];

# Users
users.users.admin = {
isNormalUser = true;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAA..." ];
};

system.stateVersion = "24.05";
}

Init System

NixBSD uses rc.d (FreeBSD's init system) instead of systemd. NixOS module options that map to systemd services are translated to rc.d equivalents where possible.

Define a custom rc.d service:

nix
rc.services.myapp = {
description = "My application";
command = "${pkgs.myapp}/bin/myapp";
commandArgs = "--config /etc/myapp/config.toml";
after = [ "network" ];
enable = true;
};

Key Differences from NixOS

AspectNixOS (Linux)NixBSD (FreeBSD)
Init systemsystemdrc.d
KernelLinuxFreeBSD
ZFSvia OpenZFS moduleNative in-kernel
JailsNot availableNative FreeBSD jails
Ports / pkgNot applicableAvailable alongside nix
GEOMNot availableNative disk framework
CapsicumNot availableNative sandboxing

Status

NixBSD is experimental. Not all NixOS modules have BSD equivalents. Areas with good support:

• Base system, shell, CLI packages
• SSH, basic networking
• ZFS filesystem
• User management

Areas still in progress or unsupported:

• Full desktop/GUI stack
• Many systemd-dependent NixOS services
• Some nixpkgs packages that assume Linux

OpenBSD

The repository also includes preliminary support for OpenBSD configurations. See the openbsd/ modules directory in the repo.