Commit 06b05d22 authored by Artemis Tosini's avatar Artemis Tosini Committed by John Ericson
Browse files

freebsd: Cleanup, get ready to support version 14



* Extend libc

  Include non-libc core libraries in the libc package. Many of these
  mirror libraries present in glibc on linux, such as libgcc, libraries
  used for iconv, and libraries used for reading kernel info (libkvm,
  libprocstat, libmemstat).

  Without this many packages outside the freebsd tree would need to be
  modified to include standard dependencies which would already be on
  the system for other packages.

* Mark FreeBSD as using LLVM

* Update default LLVM version FreeBSD

* Use patch monolith

  The patchesRoot system combined with the fact that each derivation
  will Request specific names of patches makes it very annoying to use
  other FreeBSD source trees with nixpkgs. This new system allows
  providing one Or more entire trees of patches whose contents will be
  dynamically Parsed and only the relevant patches will be applied for
  any one Derivation.

  With this commit, the following knobs are available for specifying the
  FreeBSD source:

  - overriding `freebsd.versionInfo`, for picking another official
    supported FreeBSD release.

  - overriding `freebsd.source` for specifying a specific unpatched
    FreeBSD source tree.

  - overriding `freebsd.patches`, for specifying the patches to apply.

Co-Authored-by: default avatarAudrey Dutcher <audrey@rhelmot.io>
Co-Authored-by: default avatarJohn Ericson <John.Ericson@Obsidian.Systems>
parent f5710818
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ let
        && final.parsed.kernel == platform.parsed.kernel;
      isCompatible = _: throw "2022-05-23: isCompatible has been removed in favor of canExecute, refer to the 22.11 changelog for details";
      # Derived meta-data
      useLLVM = final.isFreeBSD;

      libc =
        /**/ if final.isDarwin              then "libSystem"
        else if final.isMinGW               then "msvcrt"
+21 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ lib.packagesFromDirectoryRecursive {
}
// {
  inherit sourceData patchesRoot versionData;
  patches = ./patches/${self.versionData.revision};

  # Keep the crawled portion of Nixpkgs finite.
  buildFreebsd = lib.dontRecurseIntoAttrs buildFreebsd;
@@ -26,7 +27,8 @@ lib.packagesFromDirectoryRecursive {
    sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
  };

  compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
  compatIsNeeded = !stdenvNoCC.hostPlatform.isFreeBSD;
  compatIfNeeded = lib.optional self.compatIsNeeded self.compat;
  freebsd-lib = import ./lib {
    version = lib.concatStringsSep "." (
      map toString (
@@ -44,7 +46,7 @@ lib.packagesFromDirectoryRecursive {

  compat = self.callPackage ./pkgs/compat/package.nix {
    inherit stdenv;
    inherit (buildFreebsd) makeMinimal boot-install;
    inherit (buildFreebsd) makeMinimal;
  };

  csu = self.callPackage ./pkgs/csu.nix {
@@ -52,13 +54,11 @@ lib.packagesFromDirectoryRecursive {
    inherit (self) include;
  };

  include = self.callPackage ./pkgs/include/package.nix {
    inherit (buildFreebsd) makeMinimal install rpcgen;
  };
  include = self.callPackage ./pkgs/include/package.nix { inherit (buildFreebsd) rpcgen mtree; };

  install = self.callPackage ./pkgs/install.nix {
    inherit (buildFreebsd) makeMinimal;
    inherit (self) mtree libnetbsd;
    inherit (self) libmd libnetbsd;
  };

  libc = self.callPackage ./pkgs/libc/package.nix {
@@ -67,16 +67,30 @@ lib.packagesFromDirectoryRecursive {
      install
      gencat
      rpcgen
      mkcsmapper
      mkesdb
      ;
    inherit (self) csu include;
  };

  libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix { inherit (buildFreebsd) makeMinimal; };

  libmd = self.callPackage ./pkgs/libmd.nix { inherit (buildFreebsd) makeMinimal; };

  mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
    inherit stdenv;
    inherit (buildFreebsd) makeMinimal install tsort;
    inherit (buildFreebsd)
      freebsdSetupHook
      makeMinimal
      install
      tsort
      lorder
      ;
  };

  makeMinimal = self.callPackage ./pkgs/makeMinimal.nix { inherit (self) make; };

  mtree = self.callPackage ./pkgs/mtree.nix { inherit (self) libnetbsd libmd; };

  tsort = self.callPackage ./pkgs/tsort.nix { inherit (buildFreebsd) makeMinimal install; };
}
+13 −0
Original line number Diff line number Diff line
--- a/contrib/mtree/Makefile	2023-12-04 23:02:13.919144141 -0700
+++ b/contrib/mtree/Makefile		2023-12-04 23:02:58.371810109 -0700
@@ -10,8 +10,8 @@
 SRCS=  compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \
        verify.c getid.c pack_dev.c only.c
 .if (${HOSTPROG:U} == "")
-DPADD+= ${LIBUTIL}
-LDADD+= -lutil
+LIBADD+= ${LIBUTIL}
+#LIBADD+= -lutil
 .endif

 CPPFLAGS+=	-I${NETBSDSRCDIR}/sbin/mknod
+17 −7
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
  lib,
  stdenv,
  mkDerivation,
  patchesRoot,
  versionData,
  bsdSetupHook,
  freebsdSetupHook,
  makeMinimal,
@@ -17,7 +17,7 @@ let
  inherit (freebsd-lib) mkBsdArch;
in

mkDerivation rec {
mkDerivation {
  pname = "compat";
  path = "tools/build";
  extraPaths =
@@ -80,6 +80,12 @@ mkDerivation rec {
      "sys/sys/font.h"
      "sys/sys/consio.h"
      "sys/sys/fnv_hash.h"
      #"sys/sys/cdefs.h"
      #"sys/sys/param.h"
      "sys/sys/_null.h"
      #"sys/sys/types.h"
      "sys/sys/_pthreadtypes.h"
      "sys/sys/_stdint.h"

      "sys/crypto/chacha20/_chacha.h"
      "sys/crypto/chacha20/chacha.h"
@@ -92,11 +98,10 @@ mkDerivation rec {

      "lib/libcapsicum"
      "lib/libcasper"
    ];
      "lib/libmd"

  patches = [
    /${patchesRoot}/compat-install-dirs.patch
    /${patchesRoot}/compat-fix-typedefs-locations.patch
      # idk bro
      "sys/sys/kbio.h"
    ];

  preBuild =
@@ -151,4 +156,9 @@ mkDerivation rec {
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      cp --no-preserve=mode -r cross-build/include/darwin/* $out/1-include
    '';

  # Compat is for making other platforms look like FreeBSD (e.g. to
  # build build-time dependencies for building FreeBSD packages). It is
  # not needed when building for FreeBSD.
  meta.broken = stdenv.hostPlatform.isFreeBSD;
}
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
}:

mkDerivation {
  isStatic = true;
  path = "lib/csu";
  extraPaths = [
    "lib/Makefile.inc"
Loading