-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revive FreeBSD stdenv #254801
Revive FreeBSD stdenv #254801
Conversation
The reason we pulled it out is because these "impure" stdenvs are had to maintain and cannot be reasonably cached by We've improved cross compiling to FreeBSD and NetBSD, and in NixOS/nix#8887 I have added CI for cross compiling Nix itself. The next step is to create a bootstrap tools (which will at least initially be cross compiled) and boot from it natively, purely. |
I know I've been saying this for a while, and thus it appears I need to actually sit down and make it myself or pair with someone on it. I so far have been too busy to do that. |
That's great. I think this PR sets up a solid base for being able to do that, since the impure bits are very precisely quarantined. I can try to get a nixos install later today and see what the interaction between your PR and this one looks like. Is there a channel I should join on matrix to talk to you about this? So far, I've just been dumping progress into #exotic:nixos.org. |
Yeah we can talk a bit. But I am afraid I don't currently envision any overlap between this and the thing I want. |
lib/systems/examples.nix
Outdated
@@ -321,7 +321,7 @@ rec { | |||
# BSDs | |||
|
|||
x86_64-freebsd = { | |||
config = "x86_64-unknown-freebsd13"; | |||
config = "x86_64-freebsd13"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gnu-config says this used to be correct and is wrong now
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
why change?
+ ln -s $(LIBRHASH_SHARED) $(LIBDIR)/$(LIBRHASH_SO_MAJ) || true | ||
@@ -180,1 +180,1 @@ | ||
- ln -s $(LIBRHASH_SHARED) $(LIBRHASH_SO_MAJ) | ||
+ ln -s $(LIBRHASH_SHARED) $(LIBRHASH_SO_MAJ) || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does freebsd not support symlinks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hackfix for an issue that will be fixed in the next version of rhash. I believe this is the relevant issue: rhash/RHash#246
@@ -189,6 +189,10 @@ in lib.makeExtensible (self: ({ | |||
nix_2_17 = common { | |||
version = "2.17.0"; | |||
hash = "sha256-QMYAkdtU+g9HlZKtoJ+AI6TbWzzovKGnPZJHfZdclc8="; | |||
patches = lib.optionals aws-sdk-cpp.stdenv.hostPlatform.isFreeBSD [ | |||
./patches/FreeBSD-tests-restricted.sh.patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All nix changes should be submitted upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Artturin I suppose is more positive, but just to be clear I am still quite against this.
Once/During @emilytrau is done with the bootstrap overhaul, it is a perfect time to simply the other bootstrapping so making a pure FreeBSD boostrap is easier.
I agree too that impure bootstraps should not be used, instead cross-compiled bootstrap tools should be used if they're available. Some changes here could apply to cross-compilation too. I think there's no need to wait for minimal-bootstrap to be ready because the programs needed are likely not going to support *BSD anytime soon |
I have been working on a pure bootstrap since reading John's comments. I'll switch this PR to a draft until I've got a proof of concept. |
Update! Pretty much all of the questions from the previous iteration of this PR have been resolved.
New bits...
|
My script also pulls the list of "Supported FreeBSD releases" from the FreeBSD Security page and includes that in the Note that supported branches only include Most of our testing has been on This PR currently defaults to
I would support switching the default to Unfortunately, any update will cause a mass rebuild without both ca-derivations and a fair amount of work to remove version numbers from packages. I would also be willing to support this platform, the port is a huge project and I have been contributing to it for a few months. |
Not sure if truly related, but I have an issue adding an override to the packages in this PR: diff --git pkgs/os-specific/bsd/freebsd/sys.nix pkgs/os-specific/bsd/freebsd/sys.nix
index fc42e2f0f1b6..74f1ee276d03 100644
--- pkgs/os-specific/bsd/freebsd/sys.nix
+++ pkgs/os-specific/bsd/freebsd/sys.nix
@@ -1,7 +1,6 @@
-{mkDerivation, buildPackages, buildFreebsd, hostArchBsd, patchesRoot, ... }:
-mkDerivation (let
- cfg = "GENERIC";
- in rec {
+{mkDerivation, buildPackages, buildFreebsd, hostArchBsd, patchesRoot, cfg ? "GENERIC", ... }:
+if cfg == "GENERIC" then throw "override did not work" else
+ mkDerivation (rec {
path = "sys";
extraPaths = ["include"]; With the throw in place I cannot evaluate My first guess was this additional diff --git pkgs/os-specific/bsd/freebsd/make-derivation.nix pkgs/os-specific/bsd/freebsd/make-derivation.nix
index 7a2b4fe3d966..913b8440d3a4 100644
--- pkgs/os-specific/bsd/freebsd/make-derivation.nix
+++ pkgs/os-specific/bsd/freebsd/make-derivation.nix
@@ -1,5 +1,5 @@
{ lib, crossLibcStdenv, stdenv, hostVersion, buildPackages, buildFreebsd, hostArchBsd, compatIfNeeded, filterSource, ... }:
-lib.makeOverridable (attrs: let
+attrs: let
# the use of crossLibcStdenv in the isStatic case is kind of a misnomer but I think it works
stdenv' = if (attrs.isStatic or false) then crossLibcStdenv else stdenv;
in stdenv'.mkDerivation (rec {
@@ -57,4 +57,4 @@ in stdenv'.mkDerivation (rec {
preBuild = ''
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -D_VA_LIST -D_VA_LIST_DECLARED -Dva_list=__builtin_va_list -D_SIZE_T_DECLARED -D_SIZE_T -Dsize_t=__SIZE_TYPE__ -D_WCHAR_T"
'' + (attrs.preBuild or "");
-}))
+}) |
The version number is intentionally part of the platform tuple and should stay that way. It is probably necessary to adjust Nix' |
Can I hear more about that? My experience doing live fire testing of the versionless system has been nothing short of splendid. The only packages that put up a fight were python and gcc, and I have resolved both of them by providing the version number of userland (e.g. libc) as part of the triple even though the system double is unversioned. The explicit goal of removing the version number from the double was to make it so that we don't have to maintain multiple systems. My understanding was that this is possible because FreeBSD has excellent kernel ABI backward compatibility, a fact that seems to be obscured by decades of misinformation. Rust, for example, distributes only a single unversioned FreeBSD distribution, and that seems to be working fine for them. |
I guess it doesn't help that BSDs share some parts of the system construction practices, but are very different in the other parts. https://wiki.freebsd.org/BinaryCompatibility indeed looks like it targets absolute userland interface stability, and achieves it to the level comparable of Linux… |
If we have a switch in the nixpkgs
But is it also forwards compatible? The system value would be used to schedule remote builds. If we use the same tuple for all versions it could happen that FreeBSD 14 binaries are executed on a machine that uses an older version of FreeBSD. Would that work in all cases? |
It should work for all sane cases, that is, cases that Linux also works for. Let's say we support FreeBSD versions 13 and 14. Our default userland is therefore going to be 13, and any change to that will change derivation hashes. Therefore, if there is a 14 system servicing builds for a 13 system, it will still be using the 13 userland in its build jail, and so the binaries will link on the 13 system. However, there is always the possibility that the build system probes the kernel directly for capabilities, which can be argued to be acceptable for a non-cross build. I believe that this will also break things on Linux. True forwards compatibility, i.e. the ability for e.g. a static binary built on a new kernel to run on an old kernel, can only exist with extensive compiler or library support (fallbacks!), which is not realistic to expect in all cases. fwiw, we can also spoof the reported kernel version in the build jail, though this obviously won't affect the actual capabilities available. |
Superseded by above. This is so big as to be unmergable :) |
Description of changes
This allows the stdenv to boot on FreeBSD again. Additionally, many packages have been patched to add FreeBSD support.
Please note: I am very new here! I have never used nix before, I just wanted to learn by making it work on FreeBSD. I am very much open to feedback.
Things done
FreeBSD bootstrap files, compilable from linux
Entirely new stdenv/freebsd
Add missing parameters to let packages build on FreeBSD
Built on platform(s)
For non-Linux: Is
sandbox = true
set innix.conf
? (See Nix manual)Tested, as applicable:
Tested compilation of all packages that depend on this change using
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usageTested basic functionality of all binary files (usually in
./result/bin/
)23.11 Release Notes (or backporting 23.05 Release notes)
Fits CONTRIBUTING.md.