From 48ae217cc56cf6b732326e994f2918ba69df40c5 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Thu, 10 Oct 2024 19:24:52 -0400 Subject: [PATCH 1/3] darwin.locale: reinit at 118 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The locale data used on macOS has not been included in a source release since adv_cmds-118. Fortunately, that data can be parsed by the current version of adv_cmds. It’s a bit old, but other sources of data (such as FreeBSD) are not compatible enough and may cause divergent behavior. --- .../adv_cmds/package.nix | 7 --- .../apple-source-releases/locale/package.nix | 63 +++++++++++++++++++ .../update-source-releases.sh | 1 + pkgs/top-level/darwin-packages.nix | 2 +- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 pkgs/os-specific/darwin/apple-source-releases/locale/package.nix diff --git a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/package.nix b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/package.nix index a985d0f0da551..6463517166784 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/package.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/package.nix @@ -35,7 +35,6 @@ mkAppleDerivation { outputs = [ "out" - "locale" "ps" "man" ]; @@ -86,15 +85,9 @@ mkAppleDerivation { (lib.mesonOption "sdk_version" (lib.getVersion apple-sdk)) ]; - postBuild = '' - # Build the locales TODO - ''; - postInstall = '' - moveToOutput share/locale "$locale" moveToOutput bin/ps "$ps" ln -s "$ps/bin/ps" "$out/bin/ps" - mkdir -p "$locale/share/locale" ''; meta = { diff --git a/pkgs/os-specific/darwin/apple-source-releases/locale/package.nix b/pkgs/os-specific/darwin/apple-source-releases/locale/package.nix new file mode 100644 index 0000000000000..e9b58462f2c8d --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/locale/package.nix @@ -0,0 +1,63 @@ +{ + lib, + adv_cmds, + bmake, + fetchFromGitHub, + stdenvNoCC, +}: + +stdenvNoCC.mkDerivation { + pname = "locale"; + version = "118"; + + # This data is old, but it’s closer to what macOS has than FreeBSD. Trying to use the FreeBSD data + # results in test failures due to different behavior (e.g., with zh_CN and spaces in gnulib’s `trim` test). + # TODO(@reckenrode) Update locale data using https://cldr.unicode.org to match current macOS locale data. + src = fetchFromGitHub { + owner = "apple-oss-distributions"; + repo = "adv_cmds"; + rev = "adv_cmds-118"; + hash = "sha256-KzaAlqXqfJW2s31qmA0D7qteaZY57Va2o86aZrwyR74="; + }; + + sourceRoot = "source/usr-share-locale.tproj"; + + postPatch = '' + # bmake expects `Makefile` not `BSDmakefile`. + find . -name Makefile -exec rm {} \; -exec ln -s BSDmakefile {} \; + + # Update `Makefile`s to: get commands from `PATH`, and install to the correct location. + # Note: not every `Makefile` has `rsync` or the project name in it. + for subproject in colldef mklocale monetdef msgdef numericdef timedef; do + substituteInPlace "$subproject/BSDmakefile" \ + --replace-warn "../../$subproject.tproj/" "" \ + --replace-fail /usr/share/locale /share/locale \ + --replace-fail '-o ''${BINOWN} -g ''${BINGRP}' "" \ + --replace-warn "rsync -a" "cp -r" + done + + # Update `bsdmake` references to `bmake` + substituteInPlace Makefile \ + --replace-fail bsdmake bmake + ''; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + adv_cmds + bmake + ]; + + enableParallelInstalling = true; + + installFlags = [ "DESTDIR=${placeholder "out"}" ]; + + meta = { + description = "Locale data for Darwin"; + license = [ + lib.licenses.apsl10 + lib.licenses.apsl20 + ]; + maintainers = lib.teams.darwin.members; + }; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/update-source-releases.sh b/pkgs/os-specific/darwin/apple-source-releases/update-source-releases.sh index 36d82700a4c9f..aa852d125a0d3 100755 --- a/pkgs/os-specific/darwin/apple-source-releases/update-source-releases.sh +++ b/pkgs/os-specific/darwin/apple-source-releases/update-source-releases.sh @@ -25,6 +25,7 @@ tag="macos-${sdkVersion//.}" declare -A ignoredPackages=( [libsbuf]=1 + [locale]=1 [mkAppleDerivation]=1 [update-source-releases.sh]=1 [versions.json]=1 diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index dafb00befb406..74c5fa443f75c 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -118,7 +118,7 @@ impure-cmds // apple-source-packages // apple-source-headers // stubs // { extraBuildInputs = []; }; - inherit (self.adv_cmds) locale ps; + inherit (self.adv_cmds) ps; binutils-unwrapped = callPackage ../os-specific/darwin/binutils { inherit (pkgs) cctools; From 1d030c0ad7eadb6507978f48f90abf5c6e336644 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 11 Oct 2024 17:32:36 -0400 Subject: [PATCH 2/3] darwin.stdenv: propagate darwin.locale as a no-CC package --- pkgs/stdenv/darwin/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index cee3f98e90311..393fafaa75642 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -289,9 +289,14 @@ let ; }; - darwinPackages = prevStage: { inherit (prevStage.darwin) locale sigtool; }; + darwinPackages = prevStage: { inherit (prevStage.darwin) sigtool; }; darwinPackagesNoCC = prevStage: { - inherit (prevStage.darwin) binutils binutils-unwrapped libSystem; + inherit (prevStage.darwin) + binutils + binutils-unwrapped + libSystem + locale + ; }; # These packages are not allowed to be used in the Darwin bootstrap From 840a4f7771a0cb177695ca4c556e10b778929b49 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Thu, 10 Oct 2024 19:24:52 -0400 Subject: [PATCH 3/3] darwin.stdenv: propagate bmake from stage 1 (for darwin.locale) --- pkgs/stdenv/darwin/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 393fafaa75642..5a3ef15e392d1 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -238,6 +238,7 @@ let autoconf automake bison + bmake brotli cmake cpio