From bcaca23529cd7d51dc432ca661076a54036e1143 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:19:18 -0700 Subject: [PATCH 01/21] freebsd.compat: re-add lost patch This patch was applied to 14.0 but not 13.1. It is necessary for 13.1 as well. --- .../bsd/freebsd/patches/13.1/compat-install-dirs.patch | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch b/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch index 9bb2bea32ee9..4bc21cf8eb14 100644 --- a/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch +++ b/pkgs/os-specific/bsd/freebsd/patches/13.1/compat-install-dirs.patch @@ -2,12 +2,11 @@ diff --git a/tools/build/Makefile b/tools/build/Makefile index 948a5f9dfdb..592af84eeae 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile -@@ -327,15 +327,15 @@ host-symlinks: +@@ -327,14 +327,14 @@ host-symlinks: # and cross-tools stages. We do this here using mkdir since mtree may not exist # yet (this happens if we are crossbuilding from Linux/Mac). INSTALLDIR_LIST= \ - bin \ -- lib/casper \ - lib/geom \ - usr/include/casper \ - usr/include/private/ucl \ @@ -16,7 +15,6 @@ index 948a5f9dfdb..592af84eeae 100644 - usr/libdata/pkgconfig \ - usr/libexec + ${BINDIR} \ -+ ${LIBDIR}/casper \ + ${LIBDIR}/geom \ + ${INCLUDEDIR}/casper \ + ${INCLUDEDIR}/private/ucl \ From 295c645d807e4754b7d1f89ffdb65263cae9f042 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:24:30 -0700 Subject: [PATCH 02/21] freebsd.boot-install: wrap coreutils install instead of netbsd netbsd can no longer compile under FreeBSD native early bootstrap stdenv, so switch to coreutils. This only involves discarding the -l flag. The -l flag causes a symlink instead of a copy to be installed, so it is safe to discard during bootstrap. --- .../bsd/freebsd/pkgs/boot-install.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix b/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix index 966489d9aef3..79dab282e3f3 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix @@ -1,10 +1,23 @@ { buildPackages, freebsd-lib }: -# Wrap NetBSD's install +# Wrap GNU coreutils' install +# The -l flag causes a symlink instead of a copy to be installed, so +# it is safe to discard during bootstrap since coreutils does not support it. + buildPackages.writeShellScriptBin "boot-install" ( freebsd-lib.install-wrapper + '' + fixed_args=() + while [[ ''${#args[0]} > 0 ]]; do + case "''${args[0]}" in + -l) + args=("''${args[@]:2}") + continue + esac + fixed_args+=("''${args[0]}") + args=("''${args[@]:1}") + done - ${buildPackages.netbsd.install}/bin/xinstall "''${args[@]}" + ${buildPackages.coreutils}/bin/install "''${fixed_args[@]}" '' ) From 2785d4f4aea77ac220eb329bc7c028f9819e9bff Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:26:02 -0700 Subject: [PATCH 03/21] freebsd.filterSource: use a less featureful rsync By adding fewer dependencies, the FreeBSD native bootstrap tarball becomes lighter. --- .../bsd/freebsd/pkgs/filterSource.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix b/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix index dc215c18aecb..09674056d9cd 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix @@ -18,6 +18,17 @@ let lib.concatMapStringsSep "\n" (path: "/${path}") sortedPaths ); in -runCommand "${pname}-filtered-src" { nativeBuildInputs = [ pkgsBuildBuild.rsync ]; } '' - rsync -a -r --files-from=${filterText} ${source}/ $out -'' +runCommand "${pname}-filtered-src" + { + nativeBuildInputs = [ + (pkgsBuildBuild.rsync.override { + enableZstd = false; + enableXXHash = false; + enableOpenSSL = false; + enableLZ4 = false; + }) + ]; + } + '' + rsync -a -r --files-from=${filterText} ${source}/ $out + '' From ba5f1b4400d3180563fc0822bb529eaf3239875c Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:27:21 -0700 Subject: [PATCH 04/21] freebsd.mkDerivation: process patches generated with git The diff parsing was pretty hardcoded for diff -u. Now it should handle git diff/show as well. --- pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix index be195b3bc6fa..9659f92d17d7 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix @@ -128,15 +128,17 @@ lib.makeOverridable ( splitPatch = patchFile: let + allLines' = lib.strings.splitString "\n" (builtins.readFile patchFile); + allLines = builtins.filter ( + line: !((lib.strings.hasPrefix "diff --git" line) || (lib.strings.hasPrefix "index " line)) + ) allLines'; foldFunc = a: b: - if (lib.strings.hasPrefix "--- " b) then + if ((lib.strings.hasPrefix "--- " b) || (lib.strings.hasPrefix "diff --git " b)) then (a ++ [ [ b ] ]) else ((lib.lists.init a) ++ (lib.lists.singleton ((lib.lists.last a) ++ [ b ]))); - partitionedPatches' = lib.lists.foldl foldFunc [ [ ] ] ( - lib.strings.splitString "\n" (builtins.readFile patchFile) - ); + partitionedPatches' = lib.lists.foldl foldFunc [ [ ] ] allLines; partitionedPatches = if (builtins.length partitionedPatches' > 1) then (lib.lists.drop 1 partitionedPatches') From 61202561d92cf1cd74532fcbd8b9d6662c5bc57b Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:28:35 -0700 Subject: [PATCH 05/21] freebsd.{libc,compat,include}: use no-libs stdenv Previously, an attribute named isStatic did this, but this was lost in a refactor. Revive it and rename it to noLibc to be more clear about its intended use. --- pkgs/os-specific/bsd/freebsd/pkgs/csu.nix | 2 +- pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix | 2 +- pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix | 2 +- pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix b/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix index 0f74d78b1d13..020a08c1d01e 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix @@ -12,7 +12,7 @@ }: mkDerivation { - isStatic = true; + noLibc = true; path = "lib/csu"; extraPaths = [ "lib/Makefile.inc" diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix index 70734226a54f..a7ceb0cdf384 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix @@ -7,7 +7,7 @@ }: mkDerivation { - isStatic = true; + noLibc = true; path = "include"; extraPaths = [ diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix index 8f2cc976463e..a991e6926582 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix @@ -21,7 +21,7 @@ }: mkDerivation { - isStatic = true; + noLibc = true; pname = "libc"; path = "lib/libc"; extraPaths = diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix index 9659f92d17d7..c6659ac0d91c 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix @@ -2,6 +2,7 @@ lib, stdenv, stdenvNoCC, + stdenvNoLibs, versionData, writeText, patches, @@ -21,7 +22,13 @@ lib.makeOverridable ( attrs: let - stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv; + stdenv' = + if attrs.noCC or false then + stdenvNoCC + else if attrs.noLibc or false then + stdenvNoLibs + else + stdenv; in stdenv'.mkDerivation ( rec { From d78f853f7e3bf84924d54c0280f4bca2e0665d57 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:31:26 -0700 Subject: [PATCH 06/21] freebsd.libxo: init --- pkgs/os-specific/bsd/freebsd/pkgs/libxo.nix | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libxo.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libxo.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libxo.nix new file mode 100644 index 000000000000..a4882ea1970c --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libxo.nix @@ -0,0 +1,6 @@ +{ mkDerivation }: +mkDerivation { + path = "lib/libxo"; + extraPaths = [ "contrib/libxo" ]; + MK_TESTS = "no"; +} From 95fa436fbe232a7da493775eeef9a794d249de15 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:32:41 -0700 Subject: [PATCH 07/21] freebsd.libelf: init --- pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix new file mode 100644 index 000000000000..a116aff81f39 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix @@ -0,0 +1,29 @@ +{ + mkDerivation, + lib, + bsdSetupHook, + freebsdSetupHook, + makeMinimal, + install, + m4, +}: +mkDerivation { + path = "lib/libelf"; + extraPaths = [ + "lib/libc" + "contrib/elftoolchain" + "sys/sys/elf32.h" + "sys/sys/elf64.h" + "sys/sys/elf_common.h" + ]; + buildInputs = [ ]; + nativeBuildInputs = [ + bsdSetupHook + freebsdSetupHook + makeMinimal + install + m4 + ]; + + meta.platforms = lib.platforms.freebsd; +} From d792ea2d412b9229bbb265d08e3b07a669d696d2 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:33:47 -0700 Subject: [PATCH 08/21] freebsd.{libncurses,libncurses-tinfo}: init These packages are preferred over libncurses proper for some in-tree FreeBSD packages. --- .../freebsd/patches/14.0/tinfo-host-cc.patch | 15 +++++++++++ .../bsd/freebsd/pkgs/libncurses-tinfo.nix | 15 +++++++++++ .../bsd/freebsd/pkgs/libncurses.nix | 25 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/tinfo-host-cc.patch create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libncurses-tinfo.nix create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libncurses.nix diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/tinfo-host-cc.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/tinfo-host-cc.patch new file mode 100644 index 000000000000..6446322a8a0a --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/tinfo-host-cc.patch @@ -0,0 +1,15 @@ +--- a/lib/ncurses/tinfo/Makefile 2023-12-26 23:02:07.827892619 -0800 ++++ b/lib/ncurses/tinfo/Makefile 2023-12-26 23:01:24.175546100 -0800 +@@ -282,10 +282,10 @@ + build-tools: make_hash make_keys + + make_keys: make_keys.c names.c ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META} +- ${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} ${NCURSES_DIR}/ncurses/tinfo/make_keys.c ++ ${CC_HOST:N${CCACHE_BIN}} -o $@ ${CFLAGS} ${NCURSES_DIR}/ncurses/tinfo/make_keys.c + + make_hash: make_hash.c hashsize.h ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META} +- ${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \ ++ ${CC_HOST:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \ + ${NCURSES_DIR}/ncurses/tinfo/make_hash.c + .endif + .if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host" diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libncurses-tinfo.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libncurses-tinfo.nix new file mode 100644 index 000000000000..f86f78dbc291 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libncurses-tinfo.nix @@ -0,0 +1,15 @@ +{ mkDerivation, pkgsBuildBuild }: +mkDerivation { + path = "lib/ncurses/tinfo"; + extraPaths = [ + "lib/ncurses" + "contrib/ncurses" + "lib/Makefile.inc" + ]; + CC_HOST = "${pkgsBuildBuild.stdenv.cc}/bin/cc"; + MK_TESTS = "no"; + preBuild = '' + export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -D_VA_LIST -D_VA_LIST_DECLARED -Dva_list=__builtin_va_list -D_SIZE_T -D_WCHAR_T" + make $makeFlags "CFLAGS=-D_VA_LIST -D_VA_LIST_DECLARED -Dva_list=__builtin_va_list -I$BSDSRCDIR/contrib/ncurses/ncurses -I$BSDSRCDIR/contrib/ncurses/include -I." ncurses_dll.h make_hash make_keys + ''; +} diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libncurses.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libncurses.nix new file mode 100644 index 000000000000..2dd1ee2fe57d --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libncurses.nix @@ -0,0 +1,25 @@ +{ + lib, + versionData, + mkDerivation, + libncurses-tinfo, + ... +}: +mkDerivation { + path = "lib/ncurses/ncurses"; + extraPaths = [ + "lib/ncurses" + "contrib/ncurses" + "lib/Makefile.inc" + ]; + MK_TESTS = "no"; + preBuild = lib.optionalString (versionData.major == 14) '' + make -C ../tinfo $makeFlags curses.h ncurses_dll.h ncurses_def.h + ''; + buildInputs = lib.optionals (versionData.major == 14) [ libncurses-tinfo ]; + + # some packages depend on libncursesw.so.8 + postInstall = '' + ln -s $out/lib/libncursesw.so.9 $out/lib/libncursesw.so.8 + ''; +} From 98587064a0d688f9fbfc4437571734b77dde6601 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:36:40 -0700 Subject: [PATCH 09/21] freebsd.libedit: init --- pkgs/os-specific/bsd/freebsd/pkgs/libedit.nix | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libedit.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libedit.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libedit.nix new file mode 100644 index 000000000000..50b1c9f58333 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libedit.nix @@ -0,0 +1,7 @@ +{ mkDerivation, libncurses-tinfo }: +mkDerivation { + path = "lib/libedit"; + extraPaths = [ "contrib/libedit" ]; + buildInputs = [ libncurses-tinfo ]; + MK_TESTS = "no"; +} From a753d385dad0a3603ac9ddb378da1727bad9ebe3 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:37:07 -0700 Subject: [PATCH 10/21] freebsd.libjail: init --- pkgs/os-specific/bsd/freebsd/pkgs/libjail.nix | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libjail.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libjail.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libjail.nix new file mode 100644 index 000000000000..9150be559c65 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libjail.nix @@ -0,0 +1,5 @@ +{ mkDerivation }: +mkDerivation { + path = "lib/libjail"; + MK_TESTS = "no"; +} From ae993bd1e345cf4bb822bda3fce12f688cd523c4 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:37:37 -0700 Subject: [PATCH 11/21] freebsd.libdl: init --- pkgs/os-specific/bsd/freebsd/pkgs/libdl.nix | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libdl.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libdl.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libdl.nix new file mode 100644 index 000000000000..2b77a0f71662 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libdl.nix @@ -0,0 +1,9 @@ +{ mkDerivation, ... }: +mkDerivation { + path = "lib/libdl"; + extraPaths = [ + "lib/libc" + "libexec/rtld-elf" + ]; + buildInputs = [ ]; +} From 78536028670181b6e1c78b6bbbb50724dcd7cd02 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:38:32 -0700 Subject: [PATCH 12/21] freebsd.libcasper: init --- .../bsd/freebsd/pkgs/libcasper.nix | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libcasper.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libcasper.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libcasper.nix new file mode 100644 index 000000000000..df27f72bc8cb --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libcasper.nix @@ -0,0 +1,26 @@ +{ + lib, + stdenv, + mkDerivation, + libnv, +}: +mkDerivation { + path = "lib/libcasper/libcasper"; + extraPaths = [ + "lib/Makefile.inc" + "lib/libcasper" + ]; + buildInputs = [ libnv ]; + + MK_TESTS = "no"; + + makeFlags = [ + "STRIP=-s" # flag to install, not command + "CFLAGS=-DWITH_CASPER" + ] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "MK_WERROR=no"; + + postInstall = '' + make -C $BSDSRCDIR/lib/libcasper/services $makeFlags CFLAGS="-DWITH_CASPER -I$out/include" + make -C $BSDSRCDIR/lib/libcasper/services $makeFlags install + ''; +} From 892f600edd9608ee277cf8c5cb4bf31f1a677a3e Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:39:02 -0700 Subject: [PATCH 13/21] freebsd.libcapsicum: init --- pkgs/os-specific/bsd/freebsd/pkgs/libcapsicum.nix | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libcapsicum.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libcapsicum.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libcapsicum.nix new file mode 100644 index 000000000000..3cb1560df77a --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libcapsicum.nix @@ -0,0 +1 @@ +{ mkDerivation }: mkDerivation { path = "lib/libcapsicum"; } From ce0a5ce3400e952c9e400a5785dd9539dba1c2d2 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:40:55 -0700 Subject: [PATCH 14/21] freebsd.localedef: init --- .../bsd/freebsd/patches/14.0/localedef.patch | 158 ++++++++++++++++++ .../bsd/freebsd/pkgs/localedef.nix | 39 +++++ 2 files changed, 197 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/localedef.patch create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/localedef.nix diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/localedef.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/localedef.patch new file mode 100644 index 000000000000..73a0341bd324 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/localedef.patch @@ -0,0 +1,158 @@ +diff --git a/include/_ctype.h b/include/_ctype.h +index 91e6b1d14f6b..a6896b598da3 100644 +--- a/include/_ctype.h ++++ b/include/_ctype.h +@@ -44,7 +44,7 @@ + #define __CTYPE_H_ + + #include +-#include ++#include + + #define _CTYPE_A 0x00000100L /* Alpha */ + #define _CTYPE_C 0x00000200L /* Control */ +diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h +index 2d3723b49f5b..6bbff732b9d7 100644 +--- a/lib/libc/locale/collate.h ++++ b/lib/libc/locale/collate.h +@@ -36,6 +36,7 @@ + #ifndef _COLLATE_H_ + #define _COLLATE_H_ + ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/charmap.c b/usr.bin/localedef/charmap.c +index 44b7e3292eae..79c30b7cf372 100644 +--- a/usr.bin/localedef/charmap.c ++++ b/usr.bin/localedef/charmap.c +@@ -31,6 +31,7 @@ + /* + * CHARMAP file handling for localedef. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/collate.c b/usr.bin/localedef/collate.c +index 2a080773a95e..3f0030c638f5 100644 +--- a/usr.bin/localedef/collate.c ++++ b/usr.bin/localedef/collate.c +@@ -31,6 +31,7 @@ + /* + * LC_COLLATE database generation routines for localedef. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/ctype.c b/usr.bin/localedef/ctype.c +index ab7b76e57b2d..846c6d6480a8 100644 +--- a/usr.bin/localedef/ctype.c ++++ b/usr.bin/localedef/ctype.c +@@ -32,6 +32,7 @@ + /* + * LC_CTYPE database generation routines for localedef. + */ ++#include + #include + #include + +diff --git a/usr.bin/localedef/localedef.c b/usr.bin/localedef/localedef.c +index 5ff146d6f655..ed69aa1f0c0e 100644 +--- a/usr.bin/localedef/localedef.c ++++ b/usr.bin/localedef/localedef.c +@@ -32,7 +32,7 @@ + * POSIX localedef. + */ + #include +-#include ++#include + #include + #include + +diff --git a/usr.bin/localedef/messages.c b/usr.bin/localedef/messages.c +index 6b8eb9d684dd..0155821d0e56 100644 +--- a/usr.bin/localedef/messages.c ++++ b/usr.bin/localedef/messages.c +@@ -31,6 +31,7 @@ + /* + * LC_MESSAGES database generation routines for localedef. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/monetary.c b/usr.bin/localedef/monetary.c +index 7a77ac7e256c..7636c4deca1f 100644 +--- a/usr.bin/localedef/monetary.c ++++ b/usr.bin/localedef/monetary.c +@@ -31,6 +31,7 @@ + /* + * LC_MONETARY database generation routines for localedef. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/numeric.c b/usr.bin/localedef/numeric.c +index 5533b7c10e1a..9c47494f815c 100644 +--- a/usr.bin/localedef/numeric.c ++++ b/usr.bin/localedef/numeric.c +@@ -31,6 +31,7 @@ + /* + * LC_NUMERIC database generation routines for localedef. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/parser.y b/usr.bin/localedef/parser.y +index 23b3b54f8a6e..e01330f0152d 100644 +--- a/usr.bin/localedef/parser.y ++++ b/usr.bin/localedef/parser.y +@@ -33,6 +33,7 @@ + * POSIX localedef grammar. + */ + ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/scanner.c b/usr.bin/localedef/scanner.c +index c6d45a993f28..b17670ef4b4a 100644 +--- a/usr.bin/localedef/scanner.c ++++ b/usr.bin/localedef/scanner.c +@@ -32,6 +32,7 @@ + * This file contains the "scanner", which tokenizes the input files + * for localedef for processing by the higher level grammar processor. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/time.c b/usr.bin/localedef/time.c +index 7a56e244c921..0e409a742d0a 100644 +--- a/usr.bin/localedef/time.c ++++ b/usr.bin/localedef/time.c +@@ -31,6 +31,7 @@ + /* + * LC_TIME database generation routines for localedef. + */ ++#include + #include + #include + #include +diff --git a/usr.bin/localedef/wide.c b/usr.bin/localedef/wide.c +index 062e120e6912..a199cddb198d 100644 +--- a/usr.bin/localedef/wide.c ++++ b/usr.bin/localedef/wide.c +@@ -34,6 +34,7 @@ + * to the wide character forms used internally by libc. Unfortunately, + * this approach means that we need a method for each and every encoding. + */ ++#include + #include + #include + #include diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/localedef.nix b/pkgs/os-specific/bsd/freebsd/pkgs/localedef.nix new file mode 100644 index 000000000000..2e4902860c8d --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/localedef.nix @@ -0,0 +1,39 @@ +{ + mkDerivation, + lib, + stdenv, + compat, + bsdSetupHook, + byacc, + freebsdSetupHook, + makeMinimal, + install, +}: +mkDerivation ( + { + path = "usr.bin/localedef"; + + extraPaths = [ + "lib/libc/locale" + "lib/libc/stdtime" + ] ++ lib.optionals (!stdenv.hostPlatform.isFreeBSD) [ "." ]; + + nativeBuildInputs = [ + bsdSetupHook + byacc + freebsdSetupHook + makeMinimal + install + ]; + + buildInputs = [ ]; + + preBuild = lib.optionalString (!stdenv.hostPlatform.isFreeBSD) '' + export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${compat}/include -D__unused= -D__pure= -Wno-strict-aliasing" + export NIX_LDFLAGS="$NIX_LDFLAGS -L${compat}/lib" + ''; + + MK_TESTS = "no"; + } + // lib.optionalAttrs (!stdenv.hostPlatform.isFreeBSD) { BOOTSTRAPPING = 1; } +) From 2c41534d75174f30e770ac58363242cce9cfaeef Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:41:28 -0700 Subject: [PATCH 15/21] freebsd.locales: init The parameters to control which locales are built are placeholders. --- pkgs/os-specific/bsd/freebsd/pkgs/locales.nix | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/locales.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/locales.nix b/pkgs/os-specific/bsd/freebsd/pkgs/locales.nix new file mode 100644 index 000000000000..d8d3de93d5ec --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/locales.nix @@ -0,0 +1,51 @@ +{ + mkDerivation, + lib, + symlinkJoin, + bsdSetupHook, + freebsdSetupHook, + makeMinimal, + install, + tsort, + lorder, + mandoc, + groff, + localedef, + allLocales ? true, + locales ? [ "en_US.UTF-8" ], +}: +let + build = + name: needsLocaledef: + mkDerivation { + path = "share/${name}"; + + extraPaths = lib.optional needsLocaledef "tools/tools/locale/etc/final-maps"; + nativeBuildInputs = [ + bsdSetupHook + freebsdSetupHook + makeMinimal + install + tsort + lorder + mandoc + groff + ] ++ lib.optional needsLocaledef localedef; + }; + directories = { + colldef = true; + colldef_unicode = true; + ctypedef = true; + monetdef = false; + monetdef_unicode = false; + msgdef = false; + msgdef_unicode = false; + numericdef = false; + numericdef_unicode = false; + timedef = false; + }; +in +symlinkJoin { + name = "freebsd-locales"; + paths = lib.mapAttrsToList build directories; +} From fe0a405397cf84861b4b866f40142f3a2c362b54 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:42:27 -0700 Subject: [PATCH 16/21] freebsd.locale: init --- pkgs/os-specific/bsd/freebsd/pkgs/locale.nix | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/locale.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/locale.nix b/pkgs/os-specific/bsd/freebsd/pkgs/locale.nix new file mode 100644 index 000000000000..b661a7cee853 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/locale.nix @@ -0,0 +1,7 @@ +{ mkDerivation, libsbuf }: +mkDerivation { + path = "usr.bin/locale"; + buildInputs = [ libsbuf ]; + extraPaths = [ "lib/libc/locale" ]; + MK_TESTS = "no"; +} From 2bf350788ce698b1f9bd8c73bb74a53bfbce65b9 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:43:20 -0700 Subject: [PATCH 17/21] freebsd.bin: init This is a single derivation containing everything in /bin on a normal FreeBSD machine, which is an incredibly compact set of core utilities. --- pkgs/os-specific/bsd/freebsd/pkgs/bin.nix | 92 +++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/bin.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/bin.nix b/pkgs/os-specific/bsd/freebsd/pkgs/bin.nix new file mode 100644 index 000000000000..2b2738ec5794 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/bin.nix @@ -0,0 +1,92 @@ +{ + mkDerivation, + pkgsBuildBuild, + libjail, + libmd, + libnetbsd, + libcapsicum, + libcasper, + libelf, + libxo, + libncurses-tinfo, + libedit, + lib, + stdenv, + bsdSetupHook, + freebsdSetupHook, + makeMinimal, + install, + tsort, + lorder, + mandoc, + groff, + byacc, + gencat, +}: +mkDerivation { + pname = "bins"; + path = "bin"; + extraPaths = [ + "sys/conf" + "sys/sys/param.h" + "contrib/sendmail" + "contrib/tcsh" + "usr.bin/printf" + "lib/libsm" + ]; + buildInputs = [ + libjail + libmd + libnetbsd + libcapsicum + libcasper + libelf + libxo + libncurses-tinfo + libedit + ]; + nativeBuildInputs = [ + bsdSetupHook + freebsdSetupHook + makeMinimal + install + tsort + lorder + mandoc + groff + + byacc + gencat + ]; + + MK_TESTS = "no"; + + postPatch = '' + sed -E -i -e '/#define\tBSD.*/d' $BSDSRCDIR/sys/sys/param.h + sed -E -i -e '/^SYMLINKS.*/d' $BSDSRCDIR/bin/*/Makefile + sed -E -i -e 's/mktemp -t ka/mktemp -t kaXXXXXX/' $BSDSRCDIR/bin/sh/mkbuiltins $BSDSRCDIR/bin/sh/mktokens + ''; + + preBuild = '' + export NIX_CFLAGS_COMPILE="-I$BSDSRCDIR/sys $NIX_CFLAGS_COMPILE" + + make -C $BSDSRCDIR/lib/libsm $makeFlags + + make -C $BSDSRCDIR/bin/sh $makeFlags "CC=${pkgsBuildBuild.stdenv.cc}/bin/cc" CFLAGS="-D__unused= -D__printf0like\(a,b\)= -D__dead2=" ${ + lib.optionalString (!stdenv.buildPlatform.isFreeBSD) "MK_PIE=no " + }mkbuiltins mksyntax mktokens mknodes + make -C $BSDSRCDIR/bin/csh $makeFlags "CC=${pkgsBuildBuild.stdenv.cc}/bin/cc" CFLAGS="-D__unused= -D__printf0like\(a,b\)= -D__dead2= -I$BSDSRCDIR/contrib/tcsh -I." ${ + lib.optionalString (!stdenv.buildPlatform.isFreeBSD) "MK_PIE=no " + }gethost + ''; + + preInstall = '' + makeFlags="$makeFlags ROOTDIR=$out/root" + ''; + + outputs = [ + "out" + "man" + "debug" + ]; +} From 1bc374d91d74d0f0a4736196998ed2f280c3457b Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:44:04 -0700 Subject: [PATCH 18/21] freebsd.cp: init While cp is part of freebsd.bin, this particular package is critical for early stdenv boot and has its own derivation to require fewer dependencies --- pkgs/os-specific/bsd/freebsd/pkgs/cp.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/cp.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/cp.nix b/pkgs/os-specific/bsd/freebsd/pkgs/cp.nix new file mode 100644 index 000000000000..3ebfd91a4e15 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/cp.nix @@ -0,0 +1,10 @@ +{ mkDerivation }: +mkDerivation { + path = "bin/cp"; + + extraPaths = [ "sys" ]; + + postPatch = '' + substituteInPlace $BSDSRCDIR/bin/cp/Makefile --replace 'tests' "" + ''; +} From 8d5db1db1619a5b0963a3abb49600ff71ee96405 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:46:48 -0700 Subject: [PATCH 19/21] freebsd.iconv: init --- pkgs/os-specific/bsd/freebsd/pkgs/iconv.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/iconv.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/iconv.nix b/pkgs/os-specific/bsd/freebsd/pkgs/iconv.nix new file mode 100644 index 000000000000..9c1ba1835c14 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/iconv.nix @@ -0,0 +1,12 @@ +{ + mkDerivation, + libcapsicum, + libcasper, +}: +mkDerivation { + path = "usr.bin/iconv"; + buildInputs = [ + libcapsicum + libcasper + ]; +} From 41c2bba81ec7c3c03b5841ad8c981b6f98a261be Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 27 May 2024 12:48:20 -0700 Subject: [PATCH 20/21] freebsd.ldd: init --- pkgs/os-specific/bsd/freebsd/pkgs/ldd.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/ldd.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/ldd.nix b/pkgs/os-specific/bsd/freebsd/pkgs/ldd.nix new file mode 100644 index 000000000000..406e37402b2b --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/ldd.nix @@ -0,0 +1,21 @@ +{ + lib, + stdenv, + mkDerivation, + libelf, +}: +mkDerivation { + path = "usr.bin/ldd"; + extraPaths = [ + "libexec/rtld-elf" + "contrib/elftoolchain/libelf" + ]; + + buildInputs = [ libelf ]; + + env = { + NIX_CFLAGS_COMPILE = "-D_RTLD_PATH=${lib.getLib stdenv.cc.libc}/libexec/ld-elf.so.1"; + }; + + meta.platforms = lib.platforms.freebsd; +} From ae7c4ca17ff8afe9a8bc771cb68d78e6186295a5 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Thu, 30 May 2024 10:31:57 -0700 Subject: [PATCH 21/21] freebsd.libcxxrt: fixup in preparation for inclusion in stdenv - add option to build without libcxx - don't build with libcxx - distribute headers --- .../bsd/freebsd/patches/14.0/libcxxrt-headers.patch | 11 +++++++++++ pkgs/os-specific/bsd/freebsd/pkgs/libcxxrt.nix | 9 ++++++++- pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/libcxxrt-headers.patch diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/libcxxrt-headers.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/libcxxrt-headers.patch new file mode 100644 index 000000000000..256db9e2d9cf --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/libcxxrt-headers.patch @@ -0,0 +1,11 @@ +--- freebsd/lib/libcxxrt/Makefile 2024-05-30 14:27:42.328086005 -0700 ++++ freebsd/lib/libcxxrt/Makefile.mod 2024-05-30 14:27:48.048014581 -0700 +@@ -19,6 +19,8 @@ + SRCS+= terminate.cc + SRCS+= typeinfo.cc + ++INCS+=cxxabi.h unwind.h unwind-arm.h unwind-itanium.h ++ + WARNS?= 0 + CFLAGS+= -isystem ${SRCDIR} -nostdinc++ + CXXSTD?= c++14 diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libcxxrt.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libcxxrt.nix index 0640d2292d49..fd5591c0ffb8 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libcxxrt.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libcxxrt.nix @@ -1,4 +1,4 @@ -{ mkDerivation, ... }: +{ mkDerivation }: # this package is quite different from stock libcxxrt. # as of FreeBSD 14.0, it is vendored from APPROXIMATELY libcxxrt # 5d8a15823a103bbc27f1bfdcf2b5aa008fab57dd, though the vendoring mechanism is @@ -8,4 +8,11 @@ mkDerivation { pname = "libcxxrt"; path = "lib/libcxxrt"; extraPaths = [ "contrib/libcxxrt" ]; + outputs = [ + "out" + "dev" + "debug" + ]; + noLibcxx = true; + libName = "cxxrt"; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix index c6659ac0d91c..12f2c9407e3c 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix @@ -3,6 +3,8 @@ stdenv, stdenvNoCC, stdenvNoLibs, + overrideCC, + buildPackages, versionData, writeText, patches, @@ -27,6 +29,8 @@ lib.makeOverridable ( stdenvNoCC else if attrs.noLibc or false then stdenvNoLibs + else if attrs.noLibcxx or false then + overrideCC stdenv buildPackages.llvmPackages.clangNoLibcxx else stdenv; in