You can probably get at Nix 2.3 to build on FreeBSD. Due to a lack cgroups, sandboxing won’t work (like on macOS, for example).
The bigger problem than Nix, the package manager, is nixpkgs, the package repository. The FreeBSD stdenv
has massively bitrotted over the years (mainly because we don’t build a pure FreeBSD toolchain/libc, but instead reuse whatever is found on the system). A lot of packages assume libc
is built purely, so that already breaks a lot of things and the rest is probably quite broken as well, since it doesn’t see active use/testing anymore.
That being said, there has recently been interest in improving BSD support, we have decent NetBSD cross-compilation support (from Linux/macOS), with the perspective to bootstrap a pure native NetBSD stdenv
in the future.
NetBSD is the easiest of the BSDs to support of course, but work on supporting FreeBSD for cross compilation has been started, but stalled a bit for now: https://github.com/NixOS/nixpkgs/pull/82131. It would be great to see more contributions in this direction, making a NetBSD / FreeBSD stdenv in the future probably would only make sense if we have the contrributors to back up the effort. For now, however, helping on BSD support sadly implies working on Linux, since the place to start is cross-compilation support.