Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions pkgs/development/libraries/libiconv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
fetchurl,
stdenv,
lib,
darwin,
updateAutotoolsGnuConfigScriptsHook,
enableStatic ? stdenv.hostPlatform.isStatic,
enableShared ? !stdenv.hostPlatform.isStatic,
enableDarwinABICompat ? false,
enableDarwinABICompat ? stdenv.hostPlatform.isDarwin,
}:

# assert !stdenv.hostPlatform.isLinux || stdenv.hostPlatform != stdenv.buildPlatform; # TODO: improve on cross

stdenv.mkDerivation rec {
let
# libiconv is propagated by the SDK in the stdenv. Avoid an infinite recursion by using a stdenv
# with an SDK that does not try to propagate it.
stdenv' = if stdenv.hostPlatform.isDarwin then darwin.bootstrapStdenv else stdenv;
in
stdenv'.mkDerivation rec {
pname = "libiconv";
version = "1.19";

Expand All @@ -28,11 +34,25 @@ stdenv.mkDerivation rec {
# https://github.com/NixOS/nixpkgs/pull/192630#discussion_r978985593
hardeningDisable = lib.optional (stdenv.hostPlatform.libc == "bionic") "fortify";

setupHooks = [
../../../build-support/setup-hooks/role.bash
./setup-hook.sh
setupHooks =
# Match the default behavior on Darwin, which does not automatically link libiconv.
lib.optionals (!stdenv.hostPlatform.isDarwin) [
../../../build-support/setup-hooks/role.bash
./setup-hook.sh
];

patches = [
# Add support for the UTF-8-MAC encoding. This is needed for correct behavior of applications that interact with
# the filesystem on Darwin because it uses a variant of NFD to store filenames.
(fetchurl {
url = "https://raw.githubusercontent.com/macports/macports-ports/ce1083dbec406fcea0f2678308ae85639798aa6e/textproc/libiconv/files/patch-utf8mac.diff";
hash = "sha256-aqoTDIunKnWLHPizdWbU6eCDZXaj2s+GJwtg6Spzfio=";
})
];

# The patch for UTF-8-MAC requires -p0. It can’t use `fetchpatch2` because that results in an infinite recursion.
patchFlags = [ "-p0" ];

postPatch =
lib.optionalString
(
Expand Down Expand Up @@ -82,6 +102,12 @@ stdenv.mkDerivation rec {
# remove after gnulib is updated
++ lib.optional stdenv.hostPlatform.isCygwin "gl_cv_clean_version_stddef=yes";

preBuild = ''
# The UTF-8-MAC patch requires regenerating `flags.h`
make -C lib genflags
lib/genflags > lib/flags.h
'';

passthru = { inherit setupHooks; };

meta = {
Expand All @@ -104,6 +130,6 @@ stdenv.mkDerivation rec {
mainProgram = "iconv";

# This library is not needed on GNU platforms.
hydraPlatforms = with lib.platforms; cygwin ++ darwin ++ freebsd;
hydraPlatforms = lib.platforms.cygwin ++ lib.platforms.darwin ++ lib.platforms.freebsd;
};
}
11 changes: 4 additions & 7 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ let
sdkPackages = prevStage: {
inherit (prevStage)
bashNonInteractive
libiconvReal
libpng
libxml2
libxo
Expand All @@ -291,7 +292,6 @@ let
Csu
adv_cmds
copyfile
libiconv
libresolv
libsbuf
libutil
Expand Down Expand Up @@ -557,9 +557,6 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
# Use this stage’s CF to build CMake. It’s required but can’t be included in the stdenv.
cmake = self.cmakeMinimal;

# Use libiconvReal with gettext to break an infinite recursion.
gettext = super.gettext.override { libiconv = super.libiconvReal; };

# Disable grep’s tests for now due to impure locale updates in
# macOS 15.4 breaking them in the bootstrap.
gnugrep = super.gnugrep.overrideAttrs { doCheck = false; };
Expand Down Expand Up @@ -1050,6 +1047,7 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
ld64.lib
ld64.out
libffi.out
libiconv.out
libxml2.out
ncurses.dev
ncurses.man
Expand All @@ -1076,7 +1074,6 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
binutils
binutils.bintools
libcxx
libiconv.out
libresolv.out
libsbuf.out
libSystem
Expand Down Expand Up @@ -1192,8 +1189,8 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
assert isFromNixpkgs prevStage.binutils-unwrapped.src;
assert isBuiltByNixpkgsCompiler prevStage.curl;

# libiconv should be an alias for darwin.libiconv
assert prevStage.libiconv == prevStage.darwin.libiconv;
# libiconv should be an alias for libiconvReal
assert prevStage.libiconv == prevStage.libiconvReal;

{
inherit (prevStage) config overlays stdenv;
Expand Down
2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6674,8 +6674,6 @@ with pkgs;
]
then
libcIconv pkgs.libc
else if stdenv.hostPlatform.isDarwin then
darwin.libiconv
else
libiconvReal;

Expand Down
Loading