Status of FreeBSD

What is the current situation re Nix package manager on top of FreeBSD? I see the home page of the project only mentions Linux and MacOS now. From MacOS to FreeBSD it doesn’t seem like a huge stretch but on the other hand I remember reading Nix used cgroups somehow.

I don’t like where Linux is going, and I’d like to switch my own devices to BSD where possible.

What is the current situation re Nix package manager on top of
FreeBSD? I see the home page of the project only mentions Linux and
MacOS now.

I’m dual booting NixOS and FreeBSD at the moment - pkg tells me that
only version 2.3.10_1 is packaged in repos (for reference, 2.6.1 was
tagged two days ago, though nixpkgs-21.11 is on 2.3.16 by default).
Maintenance on the repo responsible for the port[0] seems to have slowed
(last commit roughly a year ago). And, while the official install script
has its own flaws, it’s still much more cohesive than the port (which
doesn’t even make the /nix directory by default).

I’d guess that Nix on FreeBSD is in the ‘theoretically possible with
lots of manual labour’ stage. RFC 46 places (x86) FreeBSD on Tier 7: no
support, but a clear path is present. With sufficient interest and
community activity, it’s probably possible to start climbing the tiers.
(And, actually, I’ve got some free time and a FreeBSD partition today,
so I might see what packaging later versions looks like…)

I remember reading Nix used cgroups somehow.

I’m not sure this is the case, or at least it isn’t necessarily the case
in all situations - MacOS doesn’t support cgroups, and Nix runs on that!

[0] https://github.com/0mp/freebsd-ports-nix

3 Likes

Maybe not directly an answer to your question, but NetBSD support has recently seen some more activity: https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+netbsd+is%3Aclosed

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.

4 Likes

NetBSD is the easiest of the BSDs to support of course

Sorry for my ignorance - why is that?

Apologies, that’s not quite obvious. I think what makes NetBSD easier is twofold:

  1. They use a GNU toolchain (albeit a patched and outdated one). In practice we were able to just use our normal GNU cross toolchain for building NetBSD packages. Today this could probably be not as important anymore, as the LLVM cross toolchain was in a much worse state when the NetBSD project was started.
  2. NetBSD emphasizes ABI/API compatibility. In particular, NetBSD (kernel) releases won’t break the syscall interface which means that binaries cross compiled from nixpkgs will keep working in the future. As I understand it, FreeBSD and in particular OpenBSD do on occasion break their interfaces, so the used libc and kernel must match. This just means more effort and maintenance is involved with supporting them, as we have more urgency to keep up with upstream and potentially need to support multiple versions of the target OS (multiple libc versions etc.).
1 Like

Thanks for the clear explanation.

In general I’d be interested in ways to organize a proper BSD effort. The problem is probably that we’d best recuit some BSD users, but for now there’s only things to be done on Linux (i.e. getting cross support ready to later cross compile the native bootstrap-tools) and we’d also need to motivate the larger community enough for the effort of course.

1 Like

Are there any developments on this? I tried nix on FreeBSD, but I am clearly not getting anywhere…

@qyliss got NetBSD cross working, and is chipping away at NetBSD native. I did some FreeBSD cross but have yet to finish it.

3 Likes

Slightly OT, but I would find a blog post about the porting process to xBSD super interesting.

1 Like
Hosted by Flying Circus.