diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix index 002e2b291698..4d5978abdfde 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix @@ -336,5 +336,6 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // { # To be removed, once I figure out how to build a newer Security version. Security = applePackage "Security/boot.nix" "osx-10.9.5" "sha256-7qr0IamjCXCobIJ6V9KtvbMBkJDfRCy4C5eqpHJlQLI=" {}; + libiconv = callPackage ./libiconv/package.nix { }; libsbuf = callPackage ./libsbuf/package.nix { }; } diff --git a/pkgs/by-name/li/libiconv-darwin/meson.build b/pkgs/os-specific/darwin/apple-source-releases/libiconv/meson.build.in similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/meson.build rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/meson.build.in diff --git a/pkgs/by-name/li/libiconv-darwin/meson.options b/pkgs/os-specific/darwin/apple-source-releases/libiconv/meson.options similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/meson.options rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/meson.options diff --git a/pkgs/by-name/li/libiconv-darwin/nixpkgs_test.c b/pkgs/os-specific/darwin/apple-source-releases/libiconv/nixpkgs_test.c similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/nixpkgs_test.c rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/nixpkgs_test.c diff --git a/pkgs/by-name/li/libiconv-darwin/package.nix b/pkgs/os-specific/darwin/apple-source-releases/libiconv/package.nix similarity index 51% rename from pkgs/by-name/li/libiconv-darwin/package.nix rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/package.nix index e928cd999165..add64547cce9 100644 --- a/pkgs/by-name/li/libiconv-darwin/package.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libiconv/package.nix @@ -1,81 +1,68 @@ { lib, - stdenv, - fetchFromGitHub, atf, gperf, - libiconvReal, - meson, - ninja, + mkAppleDerivation, pkg-config, - gitUpdater, + stdenv, }: let inherit (stdenv) hostPlatform; in -stdenv.mkDerivation (finalAttrs: { - pname = "libiconv"; - version = "99"; +mkAppleDerivation (finalAttrs: { + releaseName = "libiconv"; outputs = [ "out" "dev" ]; + xcodeHash = "sha256-wTKaRMqKC6T/nxJIEr6IlRGgsPwObgi/spw5gk2lACg="; + + patches = + lib.optionals hostPlatform.isStatic [ + # Use gperf to implement module loading statically by looking up the module functions in the static binary. + ./patches/0001-Support-static-module-loading.patch + ] + ++ [ + # Avoid out of bounds write with ISO-2022 + ./patches/0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch + ]; + # Propagate `out` only when there are dylibs to link (i.e., don’t propagate when doing a static build). propagatedBuildOutputs = lib.optionalString (!hostPlatform.isStatic) "out"; - src = fetchFromGitHub { - owner = "apple-oss-distributions"; - repo = "libiconv"; - rev = "libiconv-${finalAttrs.version}"; - hash = "sha256-TGt6rsU52ztfW2rCqwnhMAExLbexI/59IoDOGY+XGu0="; - }; - - setupHooks = - libiconvReal.setupHooks - ++ lib.optionals hostPlatform.isStatic [ ./static-setup-hook.sh ]; - - patches = lib.optionals hostPlatform.isStatic [ ./0001-Support-static-module-loading.patch ] ++ [ - ./0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch - ]; - postPatch = '' - substitute ${./meson.build} meson.build --subst-var version - cp ${./meson.options} meson.options - - # Work around unnecessary private API usage in libcharset + # Work around unnecessary private API usage in libcharset. mkdir -p libcharset/os && cat <<-header > libcharset/os/variant_private.h #pragma once #include static inline bool os_variant_has_internal_content(const char*) { return false; } header + # Add additional test cases found while working on packaging libiconv in nixpkgs. cp ${./nixpkgs_test.c} tests/libiconv/nixpkgs_test.c '' + lib.optionalString hostPlatform.isStatic '' cp ${./static-modules.gperf} static-modules.gperf ''; - strictDeps = true; - - nativeBuildInputs = - [ - meson - ninja - ] - # Dynamic builds use `dlopen` to load modules, but static builds have to link them all. - # `gperf` is used to generate a lookup table from module to ops functions. - ++ lib.optionals hostPlatform.isStatic [ gperf ]; - - mesonBuildType = "release"; + # Dynamic builds use `dlopen` to load modules, but static builds have to link them all. + # `gperf` is used to generate a lookup table from module to ops functions. + nativeBuildInputs = lib.optionals hostPlatform.isStatic [ gperf ]; mesonFlags = [ (lib.mesonBool "tests" finalAttrs.doInstallCheck) ]; + postBuild = + # Add `libcharset.a` contents to `libiconv.a` to duplicate the reexport from `libiconv.dylib`. + lib.optionalString hostPlatform.isStatic '' + ${stdenv.cc.targetPrefix}ar qL libiconv.a libcharset.a + ''; + postInstall = - lib.optionalString (stdenv.hostPlatform.isDarwin && !hostPlatform.isStatic) '' + lib.optionalString (hostPlatform.isDarwin && !hostPlatform.isStatic) '' ${stdenv.cc.targetPrefix}install_name_tool "$out/lib/libiconv.2.dylib" \ -change '@rpath/libcharset.1.dylib' "$out/lib/libcharset.1.dylib" '' @@ -98,22 +85,12 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstallCheck ''; - passthru.updateScript = gitUpdater { rev-prefix = "libiconv-"; }; - - __structuredAttrs = true; - meta = { description = "Iconv(3) implementation"; - homepage = "https://opensource.apple.com/releases/"; - license = - with lib.licenses; - [ - bsd2 - bsd3 - ] - ++ lib.optional finalAttrs.doInstallCheck apsl10; + license = [ + lib.licenses.bsd2 + lib.licenses.bsd3 + ] ++ lib.optional finalAttrs.doInstallCheck lib.licenses.apple-psl10; mainProgram = "iconv"; - maintainers = with lib.maintainers; [ reckenrode ]; - platforms = lib.platforms.darwin; }; }) diff --git a/pkgs/by-name/li/libiconv-darwin/0001-Support-static-module-loading.patch b/pkgs/os-specific/darwin/apple-source-releases/libiconv/patches/0001-Support-static-module-loading.patch similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/0001-Support-static-module-loading.patch rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/patches/0001-Support-static-module-loading.patch diff --git a/pkgs/by-name/li/libiconv-darwin/0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch b/pkgs/os-specific/darwin/apple-source-releases/libiconv/patches/0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/patches/0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch diff --git a/pkgs/by-name/li/libiconv-darwin/static-modules.gperf b/pkgs/os-specific/darwin/apple-source-releases/libiconv/static-modules.gperf similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/static-modules.gperf rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/static-modules.gperf diff --git a/pkgs/by-name/li/libiconv-darwin/static-setup-hook.sh b/pkgs/os-specific/darwin/apple-source-releases/libiconv/static-setup-hook.sh similarity index 100% rename from pkgs/by-name/li/libiconv-darwin/static-setup-hook.sh rename to pkgs/os-specific/darwin/apple-source-releases/libiconv/static-setup-hook.sh diff --git a/pkgs/os-specific/darwin/apple-source-releases/versions.json b/pkgs/os-specific/darwin/apple-source-releases/versions.json index 3768e24dcbc7..2e8d6d49694d 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/versions.json +++ b/pkgs/os-specific/darwin/apple-source-releases/versions.json @@ -38,5 +38,9 @@ "file_cmds": { "hash": "sha256-JYy6HwmultKeZtLfaysbsyLoWg+OaTh7eJu54JkJC0Q=", "version": "264.1.1" + }, + "libiconv": { + "hash": "sha256-TGt6rsU52ztfW2rCqwnhMAExLbexI/59IoDOGY+XGu0=", + "version": "99" } } diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 11027789c5be..a2cd087a5729 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -836,6 +836,7 @@ mapAliases { libgnome-keyring3 = libgnome-keyring; # Added 2024-06-22 libgpgerror = libgpg-error; # Added 2021-09-04 libheimdal = heimdal; # Added 2022-11-18 + libiconv-darwin = darwin.libiconv; libintlOrEmpty = throw "'libintlOrEmpty' has been replaced by gettext"; # Converted to throw 2023-09-10 libixp_hg = libixp; libjpeg_drop = libjpeg_original; # Added 2020-06-05 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 17fa21ed1130..f37c8959b2c5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21241,7 +21241,7 @@ with pkgs; then libcCross else stdenv.cc.libc) else if stdenv.hostPlatform.isDarwin - then libiconv-darwin + then darwin.libiconv else libiconvReal; libcIconv = libc: let