From cc22c861e805952b75941d467d826a70a7063a80 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 15 Jun 2023 18:04:46 -0700 Subject: [PATCH 1/2] glibc: allow users of glibc/common.nix to override makeFlags This commit allows to include `makeFlags` in a glibc derivation without clobbering the flags from `common.nix` --- pkgs/development/libraries/glibc/common.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix index de9867f41d0de24..f98c0eb1c3487cd 100644 --- a/pkgs/development/libraries/glibc/common.nix +++ b/pkgs/development/libraries/glibc/common.nix @@ -161,7 +161,7 @@ stdenv.mkDerivation ({ ++ lib.optional withGd "--with-gd" ++ lib.optional (!withLibcrypt) "--disable-crypt"; - makeFlags = [ + makeFlags = (args.makeFlags or []) ++ [ "OBJCOPY=${stdenv.cc.targetPrefix}objcopy" ]; @@ -196,7 +196,7 @@ stdenv.mkDerivation ({ passthru = { inherit version; minorRelease = version; }; } -// (removeAttrs args [ "withLinuxHeaders" "withGd" "postInstall" ]) // +// (removeAttrs args [ "withLinuxHeaders" "withGd" "postInstall" "makeFlags" ]) // { src = fetchurl { From b243596eb72f12d5280447b9b817b9aa6f8e9f43 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 15 Jun 2023 18:33:39 -0700 Subject: [PATCH 2/2] glibcLocales: use more than one core to build This commit massively reduces the build latency for glibcLocales by allowing it to build in parallel. This requires passing `-j$NIX_BUILD_CORES` via the glibc-specific make variable `PARALLELMFLAGS`. This commit also fixes a preexisting bug where the glibcLocales package would ignore `preBuild` and `postBuild`. --- pkgs/development/libraries/glibc/locales.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/glibc/locales.nix b/pkgs/development/libraries/glibc/locales.nix index ed6f0a5b32ca80e..22572a003859246 100644 --- a/pkgs/development/libraries/glibc/locales.nix +++ b/pkgs/development/libraries/glibc/locales.nix @@ -10,8 +10,9 @@ , allLocales ? true, locales ? [ "en_US.UTF-8/UTF-8" ] }: -callPackage ./common.nix { inherit stdenv; } { +(callPackage ./common.nix { inherit stdenv; } { pname = "glibc-locales"; +}).overrideAttrs(finalAttrs: previousAttrs: { builder = ./locales-builder.sh; @@ -25,7 +26,7 @@ callPackage ./common.nix { inherit stdenv; } { else "--big-endian") ]; - buildPhase = '' + preBuild = (previousAttrs.preBuild or "") + '' # Awful hack: `localedef' doesn't allow the path to `locale-archive' # to be overriden, but you *can* specify a prefix, i.e. it will use # //lib/locale/locale-archive. So we use @@ -57,11 +58,15 @@ callPackage ./common.nix { inherit stdenv; } { fi echo SUPPORTED-LOCALES='${toString locales}' > ../glibc-2*/localedata/SUPPORTED - '' + '' - make localedata/install-locales \ - localedir=$out/lib/locale \ ''; + makeFlags = (previousAttrs.makeFlags or []) ++ [ + "localedata/install-locales" + "localedir=${builtins.placeholder "out"}/lib/locale" + ] ++ lib.optionals finalAttrs.finalPackage.enableParallelInstalling [ + "PARALLELMFLAGS=-j$(NIX_BUILD_CORES)" + ]; + installPhase = '' mkdir -p "$out/lib/locale" "$out/share/i18n" @@ -75,4 +80,4 @@ callPackage ./common.nix { inherit stdenv; } { ''; meta.description = "Locale information for the GNU C Library"; -} +})