core/pkgs/by-name/li/libiconv/packages.nix

45 lines
1.2 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{ ... }:
res: pkgs: super:
2024-05-13 21:24:10 +00:00
with pkgs; {
2024-05-02 00:46:19 +00:00
# GNU libc provides libiconv so systems with glibc don't need to
# build libiconv separately. Additionally, Apple forked/repackaged
# libiconv so we use that instead of the vanilla version on that OS,
# and BSDs include libiconv in libc.
#
# We also provide `libiconvReal`, which will always be a standalone libiconv,
# just in case you want it regardless of platform.
2024-05-13 21:24:10 +00:00
libiconv = if lib.elem stdenv.hostPlatform.libc [
"glibc"
"musl"
"nblibc"
"wasilibc"
] then
libcIconv (if stdenv.hostPlatform != stdenv.buildPlatform then
libcCross
else
stdenv.cc.libc)
2024-05-02 00:46:19 +00:00
# else if stdenv.hostPlatform.isDarwin
# then darwin.libiconv
2024-05-13 21:24:10 +00:00
else
libiconvReal;
2024-05-02 00:46:19 +00:00
libcIconv = libc:
let
inherit (libc) pname version;
libcDev = lib.getDev libc;
2024-05-13 21:24:10 +00:00
in runCommand "${pname}-iconv-${version}" { strictDeps = true; } ''
2024-05-02 00:46:19 +00:00
mkdir -p $out/include
ln -sv ${libcDev}/include/iconv.h $out/include
'';
libiconvReal = callPackage ./. { };
2024-05-13 21:24:10 +00:00
iconv = if lib.elem stdenv.hostPlatform.libc [ "glibc" "musl" ] then
lib.getBin stdenv.cc.libc
else if stdenv.hostPlatform.isDarwin then
lib.getBin darwin.libiconv
else
lib.getBin libiconvReal;
2024-05-02 00:46:19 +00:00
}